diff --git a/cache/cache.go b/cache/cache.go index 5affa47..56356c9 100644 --- a/cache/cache.go +++ b/cache/cache.go @@ -32,14 +32,14 @@ func New(version string) *ArtCache { var vers string = c.GetString("version") // Initialize defaults - c.SetDefault(map[string]any{}, "art") - c.SetDefault(c.version, "version") - c.SaveDefault() - c.Reset() + _ = c.SetDefault(map[string]any{}, "art") + _ = c.SetDefault(c.version, "version") + _ = c.SaveDefault() + _ = c.Reset() // Refresh if newer version detected if vers != c.version { - c.Refresh() + _ = c.Refresh() } return c @@ -211,9 +211,9 @@ func (c *ArtCache) Refresh() error { var e error // Save with initial empty data - c.Set(arts, "art") - c.Set(c.version, "version") - c.Save() + _ = c.Set(arts, "art") + _ = c.Set(c.version, "version") + _ = c.Save() addArt = func(path string, info os.FileInfo, e error) error { var a *art.Art @@ -249,9 +249,9 @@ func (c *ArtCache) Refresh() error { } // Save with new data, if no errors - c.Set(arts, "art") - c.Set(c.version, "version") - c.Save() + _ = c.Set(arts, "art") + _ = c.Set(c.version, "version") + _ = c.Save() return nil } diff --git a/cmd/arTTY/cli.go b/cmd/arTTY/cli.go index 0137e07..7585293 100644 --- a/cmd/arTTY/cli.go +++ b/cmd/arTTY/cli.go @@ -91,30 +91,32 @@ func init() { hl.Sprintf("%d: Exception", Exception), ) cli.Info("Art for your TTY.") - cli.Section( + cli.SectionAligned( "FIELDS", - "blank: Use a blank line as a separator\n", - "colors: Show terminal colors\n", - "cpu: Show cpu info\n", - "fs: Show filesystem usage\n", - "host: Show hostname\n", - "ipv4: Show IPv4 addresses\n", - "ipv6: Show IPv6 addresses\n", - "kernel: Show kernel info\n", - "os: Show operating system info\n", - "ram: Show RAM usage\n", - "shell: Show current shell\n", - "tty: Show TTY info\n", - "uptime: Show uptime", + "|", + "blank|Use a blank line as a separator.\n", + "colors|Show terminal colors.\n", + "cpu|Show cpu info.\n", + "fs|Show filesystem usage.\n", + "host|Show hostname.\n", + "ipv4|Show IPv4 addresses.\n", + "ipv6|Show IPv6 addresses.\n", + "kernel|Show kernel info.\n", + "os|Show operating system info.\n", + "ram|Show RAM usage.\n", + "shell|Show current shell.\n", + "tty|Show TTY info.\n", + "uptime|Show uptime.", ) - cli.Section( + cli.SectionAligned( "FORMATS", - "bash: Generate bash code\n", - "go: Generate go code\n", - "json: Generate JSON from image file\n", - "stdout: Render art\n", - "python: Generate python code\n", - "ruby: Generate ruby code", + "|", + "bash|Generate bash code.\n", + "go|Generate go code.\n", + "json|Generate JSON from image file.\n", + "stdout|Render art.\n", + "python|Generate python code.\n", + "ruby|Generate ruby code.", ) cli.Title = "ArTTY" @@ -262,61 +264,61 @@ func init() { func setupConfig() { // Check all and plain first if flags.all || flags.plain { - config.Set("", "art") - config.Set("", "exclude") - config.Set(false, "fit") - config.Set("", "match") + _ = config.Set("", "art") + _ = config.Set("", "exclude") + _ = config.Set(false, "fit") + _ = config.Set("", "match") } if flags.plain { - config.Set(false, "bsfact") - config.Set(false, "clear_screen") - config.Set(false, "devexcuse") - config.Set(false, "fortune") - config.Set(false, "random") - config.Set(false, "sysinfo") + _ = config.Set(false, "bsfact") + _ = config.Set(false, "clear_screen") + _ = config.Set(false, "devexcuse") + _ = config.Set(false, "fortune") + _ = config.Set(false, "random") + _ = config.Set(false, "sysinfo") } // Check all other flags if flags.bsfact { - config.Set(true, "bsfact") + _ = config.Set(true, "bsfact") } if flags.clear { - config.Set(true, "clear_screen") + _ = config.Set(true, "clear_screen") } if flags.devexcuse { - config.Set(true, "devexcuse") + _ = config.Set(true, "devexcuse") } if flags.exclude != "" { - config.Set(flags.exclude, "exclude") + _ = config.Set(flags.exclude, "exclude") } if flags.fields != "" { - config.Set(strings.Split(flags.fields, ","), "fields") - config.Set(true, "sysinfo") + _ = config.Set(strings.Split(flags.fields, ","), "fields") + _ = config.Set(true, "sysinfo") } if flags.fit { - config.Set(true, "fit") + _ = config.Set(true, "fit") } if flags.fortune { - config.Set(true, "fortune") + _ = config.Set(true, "fortune") } if flags.match != "" { - config.Set(flags.match, "match") + _ = config.Set(flags.match, "match") } if flags.random { - config.Set(true, "random") + _ = config.Set(true, "random") } if flags.sysinfo { - config.Set(true, "sysinfo") + _ = config.Set(true, "sysinfo") } } @@ -335,8 +337,8 @@ func validate() { // Validate cli flags if cli.NArg() == 1 { - config.Set(cli.Arg(0), "art") - config.Set(false, "random") + _ = config.Set(cli.Arg(0), "art") + _ = config.Set(false, "random") } else if cli.NArg() > 1 { cli.Usage(ExtraArgument) } diff --git a/cmd/arTTY/config.go b/cmd/arTTY/config.go index ea5e462..acbf332 100644 --- a/cmd/arTTY/config.go +++ b/cmd/arTTY/config.go @@ -7,19 +7,19 @@ var config *jsoncfg.JSONCfg func init() { // Initialize default values for config config = jsoncfg.New("~/.config/arTTY/rc") - config.SetDefault("", "art") - config.SetDefault(false, "bsfact") - config.SetDefault(true, "clear_screen") - config.SetDefault([]string{"light_blue"}, "dataColors") - config.SetDefault(false, "devexcuse") - config.SetDefault("", "exclude") - config.SetDefault([]string{"blue"}, "fieldColors") - config.SetDefault([]string{}, "fields") - config.SetDefault(true, "fit") - config.SetDefault(false, "fortune") - config.SetDefault("", "match") - config.SetDefault(true, "random") - config.SetDefault(true, "sysinfo") - config.SaveDefault() - config.Reset() + _ = config.SetDefault("", "art") + _ = config.SetDefault(false, "bsfact") + _ = config.SetDefault(true, "clear_screen") + _ = config.SetDefault([]string{"light_blue"}, "dataColors") + _ = config.SetDefault(false, "devexcuse") + _ = config.SetDefault("", "exclude") + _ = config.SetDefault([]string{"blue"}, "fieldColors") + _ = config.SetDefault([]string{}, "fields") + _ = config.SetDefault(true, "fit") + _ = config.SetDefault(false, "fortune") + _ = config.SetDefault("", "match") + _ = config.SetDefault(true, "random") + _ = config.SetDefault(true, "sysinfo") + _ = config.SaveDefault() + _ = config.Reset() } diff --git a/cmd/arTTY/main.go b/cmd/arTTY/main.go index 15965d9..3020e9b 100644 --- a/cmd/arTTY/main.go +++ b/cmd/arTTY/main.go @@ -1,12 +1,11 @@ package main import ( - "math/rand" + "math/rand/v2" "os" "os/exec" "path/filepath" "strings" - "time" "github.com/mjwhitta/artty" "github.com/mjwhitta/artty/art" @@ -60,7 +59,7 @@ func draw(name string, i *sysinfo.SysInfo, b, d, f string) { if config.GetBool("clear_screen") { clear = exec.Command("clear") clear.Stdout = os.Stdout - clear.Run() + _ = clear.Run() } a.SysInfo = i @@ -117,7 +116,7 @@ func generate(file string) { panic(e) } - f.WriteString(out + "\n") + _, _ = f.WriteString(out + "\n") f.Close() if e = artty.Cache.Refresh(); e != nil { @@ -186,8 +185,7 @@ func getName(arts []string) string { return "none" } - rand.Seed(time.Now().UnixNano()) - return arts[rand.Intn(len(arts))] + return arts[rand.IntN(len(arts))] } // Only return the name from config, if it is in the list @@ -281,7 +279,7 @@ func main() { case "list": list(arts) case "save": - config.Save() + _ = config.Save() case "show": hl.Println(config) case "update": diff --git a/generator/generator.go b/generator/generator.go index 270f0b0..6776fc3 100644 --- a/generator/generator.go +++ b/generator/generator.go @@ -147,11 +147,11 @@ func GenerateJSON(fn, name string) (string, string, error) { jsonOut, _ = jq.New("{}") if len(pixels) > 0 { - jsonOut.Set((len(pixels)+1)/2, "height") - jsonOut.Set(legend, "legend") - jsonOut.Set(name, "name") - jsonOut.Set(pixels, "pixels") - jsonOut.Set(len(pixels[0]), "width") + _ = jsonOut.Set((len(pixels)+1)/2, "height") + _ = jsonOut.Set(legend, "legend") + _ = jsonOut.Set(name, "name") + _ = jsonOut.Set(pixels, "pixels") + _ = jsonOut.Set(len(pixels[0]), "width") } if output, e = jsonOut.GetBlob(" "); e != nil { diff --git a/globals.go b/globals.go index d03d5bf..8f45a7c 100644 --- a/globals.go +++ b/globals.go @@ -14,4 +14,4 @@ var Cache *cache.ArtCache = cache.New(Version) var devRegex = regexp.MustCompile(`(.+)`) // Version is the package version -const Version string = "1.4.9" +const Version string = "1.4.10" diff --git a/go.mod b/go.mod index d27bf1a..40670ca 100644 --- a/go.mod +++ b/go.mod @@ -1,17 +1,17 @@ module github.com/mjwhitta/artty -go 1.19 +go 1.20 require ( - github.com/mjwhitta/cli v1.12.4 + github.com/mjwhitta/cli v1.12.5 github.com/mjwhitta/errors v1.0.3 - github.com/mjwhitta/hilighter v1.11.9 + github.com/mjwhitta/hilighter v1.11.10 github.com/mjwhitta/jq v1.5.6 github.com/mjwhitta/jsoncfg v1.6.13 - github.com/mjwhitta/log v1.6.9 + github.com/mjwhitta/log v1.6.10 github.com/mjwhitta/pathname v1.2.6 - github.com/mjwhitta/sysinfo v1.5.6 - github.com/mjwhitta/where v1.3.2 + github.com/mjwhitta/sysinfo v1.5.7 + github.com/mjwhitta/where v1.3.3 github.com/stretchr/testify v1.9.0 ) @@ -19,6 +19,6 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/mjwhitta/safety v1.11.4 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/sys v0.18.0 // indirect + golang.org/x/sys v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 856a743..a351293 100644 --- a/go.sum +++ b/go.sum @@ -2,33 +2,33 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/mjwhitta/cli v1.12.4 h1:9/GaHFszigkF3hl6gkQq9+PKLTP9koJ38jPH5MeAzKk= -github.com/mjwhitta/cli v1.12.4/go.mod h1:497aphw0WscFzb+b0S5R5U8r7yEo6aYQSe9p2WVfk0A= +github.com/mjwhitta/cli v1.12.5 h1:ybz3DY+KeRmhAHyFRapWxKYY12ehALnjjbC1oj8g8Mg= +github.com/mjwhitta/cli v1.12.5/go.mod h1:497aphw0WscFzb+b0S5R5U8r7yEo6aYQSe9p2WVfk0A= github.com/mjwhitta/errors v1.0.3 h1:0+L8/7ypucj6ufBNt8Rm2qPvJ9qwmS+TtgOJYCYb6Sw= github.com/mjwhitta/errors v1.0.3/go.mod h1:VxHM8bLMPVqkvHiYQq4Nq4sjNqPjUtKLhSF2I0wve5U= -github.com/mjwhitta/hilighter v1.11.9 h1:jC+44GMw9xe83cSypZKj3Q0+zWup/jblBw467L2Mer8= -github.com/mjwhitta/hilighter v1.11.9/go.mod h1:0db9WcxBNN3QKZZwoayq2OeQg7dJwwbCjxBEUjAyrKk= +github.com/mjwhitta/hilighter v1.11.10 h1:PjOI00Kr+NY2SpzqQMzOjZcTOJV6uurGibUq8mhRnRo= +github.com/mjwhitta/hilighter v1.11.10/go.mod h1:/6nqATH7zdFK+CDzYKdSzA0oXR+DGDHBME/Jktc5FoA= github.com/mjwhitta/jq v1.5.6 h1:Oyf/yC6+TJ6KUg3ixaklJs2GXhMOLbEU3gIEpiFJGqw= github.com/mjwhitta/jq v1.5.6/go.mod h1:Caobm8oao5AJcddjRyLbl8HVxVsC2OkBj1CmQenhU90= github.com/mjwhitta/jsoncfg v1.6.13 h1:y+6oh1Sbp8WEbifAAWIHNQ7Wv6VnqypXQkpyQVPilgY= github.com/mjwhitta/jsoncfg v1.6.13/go.mod h1:Yd/4N20dm4TjMUA9KzE5L1XwXOiW+k4IWcZeB7GSDvo= -github.com/mjwhitta/log v1.6.9 h1:HHAHeSShnS8BlpjWgMf8RG9+sfiD1ndwj/nTvBZYXGQ= -github.com/mjwhitta/log v1.6.9/go.mod h1:1Jivi6+ZSy484mNVS+eDRaAOk/ora8Su1J+CybLsKP8= +github.com/mjwhitta/log v1.6.10 h1:HJGV+7sPLsiMwbfKFp+JZ1ulzk1j7ciS99/D7HX6HM0= +github.com/mjwhitta/log v1.6.10/go.mod h1:YT8YtwmqctTAquuAd/eNKQ49G6L3nYbQiujAEA9V95E= github.com/mjwhitta/pathname v1.2.6 h1:Typr5o3gDvcc+W3tKl65fCySynsbnYHdiWOI4F4l6dc= github.com/mjwhitta/pathname v1.2.6/go.mod h1:oKeW08rlanuU5o06YeXZYhzkIbqWR/LqvzeVd+Iy5xY= github.com/mjwhitta/safety v1.11.4 h1:AeKEPOneuROKY2hCmvEZk2Up/cex1ZEZccB81G4vVTY= github.com/mjwhitta/safety v1.11.4/go.mod h1:K/LrHWgnJlD5vCe0c9tH4E2prhl4Xpl6nBelXAvuXo0= -github.com/mjwhitta/sysinfo v1.5.6 h1:kDSQxHGPr0wjWc9oCOhmLhLlrZUrV4N4R+6pix7Tmyg= -github.com/mjwhitta/sysinfo v1.5.6/go.mod h1:N6Ql9rBL9IMHu/6DRNEMEozaMcmNFH8pLWvRqj5uxgI= -github.com/mjwhitta/where v1.3.2 h1:Q52oBev1Dube8/Z9Z6tJPUCXGRZuquYm55MbQnIn8yo= -github.com/mjwhitta/where v1.3.2/go.mod h1:9FBGqqcA5lKPANyhE3+WdtNF7BrTa8MCu4z12GdB7c8= +github.com/mjwhitta/sysinfo v1.5.7 h1:9bfvFMkVugbA6kbFNC0azPaA/ZquFtS/Gzl4tX84das= +github.com/mjwhitta/sysinfo v1.5.7/go.mod h1:6QnlKlJSd+OmLT/BcfF5l8c8VHxzE7Kv/r4+FDINRPE= +github.com/mjwhitta/where v1.3.3 h1:WCvJM0If5oFOxo66fakIDJAqK7lQCKOxpSpKH/vGgwo= +github.com/mjwhitta/where v1.3.3/go.mod h1:8omAtWULh54XtUNREA+Bb8sDy/Tg8MBVvoggC8RISkw= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.21.0 h1:rF+pYz3DAGSQAxAu1CbC7catZg4ebC4UIeIhKxBZvws= +golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=