diff --git a/common/init-exporter-converter.spec b/common/init-exporter-converter.spec index fadf5cc..a8f9f62 100644 --- a/common/init-exporter-converter.spec +++ b/common/init-exporter-converter.spec @@ -6,7 +6,7 @@ Summary: Utility for converting init-exporter procfiles from v1 to v2 format Name: init-exporter-converter -Version: 0.12.0 +Version: 0.12.1 Release: 0%{?dist} Group: Development/Tools License: MIT @@ -16,7 +16,7 @@ Source0: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -BuildRequires: golang >= 1.19 +BuildRequires: golang >= 1.20 Provides: %{name} = %{version}-%{release} @@ -60,6 +60,10 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Wed Mar 06 2024 Anton Novojilov - 0.12.1-0 +- Dependencies update +- Code refactoring + * Fri Mar 10 2023 Anton Novojilov - 0.12.0-0 - Added verbose version output - Dependencies update diff --git a/go.mod b/go.mod index a12077c..a61ab9b 100644 --- a/go.mod +++ b/go.mod @@ -5,10 +5,10 @@ go 1.18 require ( github.com/essentialkaos/ek/v12 v12.102.0 github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 - github.com/funbox/init-exporter v0.25.0 + github.com/funbox/init-exporter v0.25.1 ) require ( - golang.org/x/sys v0.17.0 // indirect + golang.org/x/sys v0.18.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect ) diff --git a/go.sum b/go.sum index 20f302e..edd2a19 100644 --- a/go.sum +++ b/go.sum @@ -3,13 +3,13 @@ github.com/essentialkaos/ek/v12 v12.102.0 h1:frHp1+iElQUg4CoscVQWuVFY1QZvU0fIqAa github.com/essentialkaos/ek/v12 v12.102.0/go.mod h1:T5RaDwmg6aso4vPfMp9OSk0R5YAjGtkinlxj2kDXUbo= github.com/essentialkaos/go-simpleyaml/v2 v2.1.4 h1:B2bXdGWaQ6Xy3HTsO2DLBoNV7cbMW3KDmeeOKYLo9z0= github.com/essentialkaos/go-simpleyaml/v2 v2.1.4/go.mod h1:pVQTleUBC8xBI9+HnTF38xWBZqANNrmMAzwmUemblJg= -github.com/funbox/init-exporter v0.25.0 h1:deCskPMq6KmzT6fSOqhYCsumFZiFKWp63eI1sHke6AQ= -github.com/funbox/init-exporter v0.25.0/go.mod h1:WFmUTcRPH4shVWFw16UtjJY5JeU1QC5wAPEzMpCWYH0= +github.com/funbox/init-exporter v0.25.1 h1:xmvgrPFUPInBsZRSSB8+mMciUtw78HFN0fCeMZuRyKo= +github.com/funbox/init-exporter v0.25.1/go.mod h1:r1uzN8W6j8P5awNYmWkQNA+EpIGEKdYrGA8IGVBleN4= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= -golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y= -golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4= +golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/init-exporter-converter.go b/init-exporter-converter.go index fec147c..b102d4d 100644 --- a/init-exporter-converter.go +++ b/init-exporter-converter.go @@ -8,15 +8,13 @@ package main import ( "fmt" - "io/ioutil" "os" "runtime" - "strings" "github.com/essentialkaos/ek/v12/fmtc" - "github.com/essentialkaos/ek/v12/fsutil" "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" "github.com/essentialkaos/ek/v12/usage/completion/fish" @@ -34,7 +32,7 @@ import ( // App props const ( APP = "init-exporter-converter" - VER = "0.12.0" + VER = "0.12.1" DESC = "Utility for converting procfiles from v1 to v2 format" ) @@ -130,24 +128,7 @@ func main() { // preConfigureUI preconfigures UI based on information about user terminal func preConfigureUI() { - term := os.Getenv("TERM") - - fmtc.DisableColors = true - - if term != "" { - switch { - case strings.Contains(term, "xterm"), - strings.Contains(term, "color"), - term == "screen": - fmtc.DisableColors = false - } - } - - if !fsutil.IsCharacterDevice("/dev/stdout") && os.Getenv("FAKETTY") == "" { - fmtc.DisableColors = true - } - - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } @@ -237,7 +218,7 @@ func convert(file string) error { } if !options.GetB(OPT_IN_PLACE) { - fmt.Printf(yamlData) + fmt.Print(yamlData) return nil } @@ -349,7 +330,7 @@ func validateYaml(data string) error { // writeData writes procfile data to file func writeData(file, data string) error { - return ioutil.WriteFile(file, []byte(data), 0644) + return os.WriteFile(file, []byte(data), 0644) } // printError prints error message to console @@ -357,11 +338,6 @@ func printError(f string, a ...interface{}) { fmtc.Fprintf(os.Stderr, "{r}"+f+"{!}\n", a...) } -// printError prints warning message to console -func printWarn(f string, a ...interface{}) { - fmtc.Fprintf(os.Stderr, "{y}"+f+"{!}\n", a...) -} - // printErrorAndExit print error message and exit with exit code 1 func printErrorAndExit(f string, a ...interface{}) { printError(f, a...) @@ -376,11 +352,11 @@ func printCompletion() int { switch options.GetS(OPT_COMPLETION) { case "bash": - fmt.Printf(bash.Generate(info, "init-exporter-converter")) + fmt.Print(bash.Generate(info, "init-exporter-converter")) case "fish": - fmt.Printf(fish.Generate(info, "init-exporter-converter")) + fmt.Print(fish.Generate(info, "init-exporter-converter")) case "zsh": - fmt.Printf(zsh.Generate(info, optMap, "init-exporter-converter")) + fmt.Print(zsh.Generate(info, optMap, "init-exporter-converter")) default: return 1 } @@ -390,12 +366,7 @@ func printCompletion() int { // printMan prints man page func printMan() { - fmt.Println( - man.Generate( - genUsage(), - genAbout(""), - ), - ) + fmt.Println(man.Generate(genUsage(), genAbout(""))) } // genUsage generates usage info @@ -426,16 +397,13 @@ func genUsage() *usage.Info { // genAbout generates info about version func genAbout(gitRev string) *usage.About { about := &usage.About{ - App: APP, - Version: VER, - Desc: DESC, - Year: 2006, - Owner: "FunBox", - License: "MIT License", - UpdateChecker: usage.UpdateChecker{ - "funbox/init-exporter-converter", - update.GitHubChecker, - }, + App: APP, + Version: VER, + Desc: DESC, + Year: 2006, + Owner: "FunBox", + License: "MIT License", + UpdateChecker: usage.UpdateChecker{"funbox/init-exporter-converter", update.GitHubChecker}, AppNameColorTag: "{*}" + colorTagApp, VersionColorTag: colorTagVer,