more work

Signed-off-by: jolheiser <john.olheiser@gmail.com>
main
jolheiser 2022-10-06 17:03:44 -05:00
parent a0b8f9aa42
commit 8c3242b07e
Signed by: jolheiser
GPG Key ID: B853ADA5DA7BBF7A
4 changed files with 59 additions and 24 deletions

11
go.mod
View File

@ -2,4 +2,13 @@ module go.jolheiser.com/caniuse
go 1.19
require github.com/peterbourgon/ff/v3 v3.3.0
require (
github.com/fatih/color v1.13.0
github.com/peterbourgon/ff/v3 v3.3.0
)
require (
github.com/mattn/go-colorable v0.1.9 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
)

11
go.sum
View File

@ -1,2 +1,13 @@
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/peterbourgon/ff/v3 v3.3.0 h1:PaKe7GW8orVFh8Unb5jNHS+JZBwWUMa2se0HM6/BI24=
github.com/peterbourgon/ff/v3 v3.3.0/go.mod h1:zjJVUhx+twciwfDl0zBcFzl4dW8axCRyXE/eKY9RztQ=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=

13
main.go
View File

@ -7,8 +7,10 @@ import (
"io/fs"
"os"
"path/filepath"
"strings"
"time"
"github.com/fatih/color"
"github.com/peterbourgon/ff/v3"
)
@ -47,6 +49,17 @@ func main() {
fmt.Println(data)
}
func showFeat(d data) {
var p []string
if d.UsagePercY > 0 {
p = append(p, fmt.Sprintf("%s %s%%", resultmap["y"], color.GreenString("%f", d.UsagePercY)))
}
if d.UsagePercA > 0 {
p = append(p, fmt.Sprintf("%s %s%%", resultmap["a"], color.YellowString("%f", d.UsagePercA)))
}
percentages := strings.Join(p, " ")
}
func loadData() (Data, error) {
var data Data

View File

@ -21,7 +21,16 @@ type Data struct {
Unoff string `json:"unoff"`
} `json:"statuses"`
Cats map[string][]string `json:"cats"`
Data map[string]struct {
Data map[string]data `json:"data"`
}
type stat string
func (s stat) Bool() bool {
return s == "y"
}
type data struct {
Title string `json:"title"`
Description string `json:"description"`
Spec string `json:"spec"`
@ -43,11 +52,4 @@ type Data struct {
ChromeID string `json:"chrome_id"`
FirefoxID string `json:"firefox_id"`
WebkitID string `json:"webkit_id"`
} `json:"data"`
}
type stat string
func (s stat) Bool() bool {
return s == "y"
}