diff --git a/Makefile b/Makefile index d1cb749..96abf35 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ################################################################################ -# This Makefile generated by GoMakeGen 2.2.0 using next command: +# This Makefile generated by GoMakeGen 2.3.0 using next command: # gomakegen --mod . # # More info: https://kaos.sh/gomakegen @@ -13,6 +13,7 @@ ifdef VERBOSE ## Print verbose information (Flag) VERBOSE_FLAG = -v endif +COMPAT ?= 1.18 MAKEDIR = $(dir $(realpath $(firstword $(MAKEFILE_LIST)))) GITREV ?= $(shell test -s $(MAKEDIR)/.git && git rev-parse --short HEAD) @@ -60,7 +61,7 @@ else endif ifdef COMPAT ## Compatible Go version (String) - go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) + go mod tidy $(VERBOSE_FLAG) -compat=$(COMPAT) -go=$(COMPAT) else go mod tidy $(VERBOSE_FLAG) endif @@ -106,6 +107,6 @@ help: ## Show this info | sed 's/ifdef //' \ | awk 'BEGIN {FS = " .*?## "}; {printf " \033[32m%-14s\033[0m %s\n", $$1, $$2}' @echo -e '' - @echo -e '\033[90mGenerated by GoMakeGen 2.2.0\033[0m\n' + @echo -e '\033[90mGenerated by GoMakeGen 2.3.0\033[0m\n' ################################################################################ diff --git a/README.md b/README.md index 3200a2f..a6d338f 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ ### Installation -#### From [ESSENTIAL KAOS Public Repository](https://pkgs.kaos.st) +#### From [ESSENTIAL KAOS Public Repository](https://kaos.sh/kaos-repo) ```bash sudo yum install -y https://pkgs.kaos.st/kaos-repo-latest.el$(grep 'CPE_NAME' /etc/os-release | tr -d '"' | cut -d':' -f5).noarch.rpm @@ -43,6 +43,7 @@ Options --ruby-version, -r Install version defined in version file --info, -i Print detailed info about version --all, -a Print all available versions + --pager, -P Use pager for long output --no-progress, -np Disable progress bar and spinner --no-color, -nc Disable colors in output --help, -h Show this help message diff --git a/cli/cli.go b/cli/cli.go index 993bf29..204716f 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -29,6 +29,7 @@ import ( "github.com/essentialkaos/ek/v12/knf" "github.com/essentialkaos/ek/v12/log" "github.com/essentialkaos/ek/v12/options" + "github.com/essentialkaos/ek/v12/pager" "github.com/essentialkaos/ek/v12/passwd" "github.com/essentialkaos/ek/v12/path" "github.com/essentialkaos/ek/v12/progress" @@ -39,6 +40,7 @@ import ( "github.com/essentialkaos/ek/v12/strutil" "github.com/essentialkaos/ek/v12/system" "github.com/essentialkaos/ek/v12/terminal" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/terminal/window" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/tmp" @@ -65,7 +67,7 @@ import ( // App info const ( APP = "RBInstall" - VER = "3.1.0" + VER = "3.2.0" DESC = "Utility for installing prebuilt Ruby versions to rbenv" ) @@ -82,6 +84,7 @@ const ( OPT_RUBY_VERSION = "r:ruby-version" OPT_INFO = "i:info" OPT_ALL = "a:all" + OPT_PAGER = "P:pager" OPT_NO_COLOR = "nc:no-color" OPT_NO_PROGRESS = "np:no-progress" OPT_HELP = "h:help" @@ -150,6 +153,7 @@ var optMap = options.Map{ OPT_REHASH: {Type: options.BOOL}, OPT_ALL: {Type: options.BOOL}, OPT_INFO: {Type: options.BOOL}, + OPT_PAGER: {Type: options.BOOL}, OPT_NO_COLOR: {Type: options.BOOL}, OPT_NO_PROGRESS: {Type: options.BOOL}, OPT_HELP: {Type: options.BOOL}, @@ -236,26 +240,13 @@ func Run(gitRev string, gomod []byte) { // 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") == "" { + if !fmtc.IsColorsSupported() { fmtc.DisableColors = true - useRawOutput = true } - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true + useRawOutput = true } } @@ -267,11 +258,11 @@ func configureUI() { switch { case fmtc.IsTrueColorSupported(): - colorTagApp, colorTagVer = "{#CC1E2C}", "{#CC1E2C}" + colorTagApp, colorTagVer = "{*}{#CC1E2C}", "{#CC1E2C}" case fmtc.Is256ColorsSupported(): - colorTagApp, colorTagVer = "{#160}", "{#160}" + colorTagApp, colorTagVer = "{*}{#160}", "{#160}" default: - colorTagApp, colorTagVer = "{r}", "{r}" + colorTagApp, colorTagVer = "{*}{r}", "{r}" } if fmtc.IsTrueColorSupported() || fmtc.Is256ColorsSupported() { @@ -553,6 +544,12 @@ func listCommand() { // printPrettyListing print info about listing with colors in table view func printPrettyListing(dist, arch string) { + if options.GetB(OPT_PAGER) { + if pager.Setup() == nil { + defer pager.Complete() + } + } + ruby := repoIndex.GetCategoryData(dist, arch, index.CATEGORY_RUBY, options.GetB(OPT_ALL)) jruby := repoIndex.GetCategoryData(dist, arch, index.CATEGORY_JRUBY, options.GetB(OPT_ALL)) truffle := repoIndex.GetCategoryData(dist, arch, index.CATEGORY_TRUFFLE, options.GetB(OPT_ALL)) @@ -1826,7 +1823,7 @@ func printMan() { func genUsage() *usage.Info { info := usage.NewInfo("", "version") - info.AppNameColorTag = "{*}" + colorTagApp + info.AppNameColorTag = colorTagApp info.AddOption(OPT_REINSTALL, "Reinstall already installed version {s-}(if allowed in configuration file){!}") info.AddOption(OPT_UNINSTALL, "Uninstall already installed version {s-}(if allowed in configuration file){!}") @@ -1837,6 +1834,7 @@ func genUsage() *usage.Info { info.AddOption(OPT_RUBY_VERSION, "Install version defined in version file") info.AddOption(OPT_INFO, "Print detailed info about version") info.AddOption(OPT_ALL, "Print all available versions") + info.AddOption(OPT_PAGER, "Use pager for long output") info.AddOption(OPT_NO_PROGRESS, "Disable progress bar and spinner") info.AddOption(OPT_NO_COLOR, "Disable colors in output") info.AddOption(OPT_HELP, "Show this help message") @@ -1856,10 +1854,15 @@ 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, + App: APP, + Version: VER, + Desc: DESC, + Year: 2006, + + AppNameColorTag: colorTagApp, + VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + Owner: "ESSENTIAL KAOS", License: "Apache License, Version 2.0 ", UpdateChecker: usage.UpdateChecker{"essentialkaos/rbinstall", update.GitHubChecker}, @@ -1869,10 +1872,5 @@ func genAbout(gitRev string) *usage.About { about.Build = "git:" + gitRev } - if fmtc.Is256ColorsSupported() { - about.AppNameColorTag = "{*}" + colorTagApp - about.VersionColorTag = colorTagVer - } - return about } diff --git a/clone/clone.go b/clone/clone.go index eddf655..9ee1e6c 100644 --- a/clone/clone.go +++ b/clone/clone.go @@ -13,7 +13,6 @@ import ( "io" "os" "runtime" - "strings" "time" "github.com/essentialkaos/ek/v12/fmtc" @@ -27,6 +26,7 @@ import ( "github.com/essentialkaos/ek/v12/progress" "github.com/essentialkaos/ek/v12/req" "github.com/essentialkaos/ek/v12/terminal" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" @@ -43,7 +43,7 @@ import ( // App info const ( APP = "RBInstall Clone" - VER = "3.0.3" + VER = "3.1.0" DESC = "Utility for cloning RBInstall repository" ) @@ -139,24 +139,11 @@ func Run(gitRev string, gomod []byte) { // 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") == "" { + if !fmtc.IsColorsSupported() { fmtc.DisableColors = true } - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } @@ -172,11 +159,11 @@ func configureUI() { switch { case fmtc.IsTrueColorSupported(): - colorTagApp, colorTagVer = "{#CC1E2C}", "{#CC1E2C}" + colorTagApp, colorTagVer = "{*}{#CC1E2C}", "{#CC1E2C}" case fmtc.Is256ColorsSupported(): - colorTagApp, colorTagVer = "{#160}", "{#160}" + colorTagApp, colorTagVer = "{*}{#160}", "{#160}" default: - colorTagApp, colorTagVer = "{r}", "{r}" + colorTagApp, colorTagVer = "{*}{r}", "{r}" } } @@ -526,7 +513,7 @@ func printMan() { func genUsage() *usage.Info { info := usage.NewInfo("", "url", "path") - info.AppNameColorTag = "{*}" + colorTagApp + info.AppNameColorTag = colorTagApp info.AddOption(OPT_YES, `Answer "yes" to all questions`) info.AddOption(OPT_NO_COLOR, "Disable colors in output") @@ -548,11 +535,13 @@ func genAbout(gitRev string) *usage.About { Version: VER, Desc: DESC, Year: 2006, - Owner: "ESSENTIAL KAOS", - License: "Apache License, Version 2.0 ", - AppNameColorTag: "{*}" + colorTagApp, + AppNameColorTag: colorTagApp, VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", + + Owner: "ESSENTIAL KAOS", + License: "Apache License, Version 2.0 ", } if gitRev != "" { diff --git a/common/rbinstall.spec b/common/rbinstall.spec index 748577b..b2c7904 100644 --- a/common/rbinstall.spec +++ b/common/rbinstall.spec @@ -10,7 +10,7 @@ Summary: Utility for installing prebuilt Ruby to rbenv Name: rbinstall -Version: 3.1.2 +Version: 3.2.0 Release: 0%{?dist} Group: Applications/System License: Apache License, Version 2.0 @@ -38,7 +38,7 @@ Utility for installing different prebuilt versions of Ruby to rbenv. %package gen Summary: Utility for generating RBInstall index -Version: 3.1.0 +Version: 3.2.0 Release: 0%{?dist} Group: Development/Tools @@ -50,7 +50,7 @@ Utility for generating RBInstall index. %package clone Summary: Utility for cloning RBInstall repository -Version: 3.0.5 +Version: 3.1.0 Release: 0%{?dist} Group: Development/Tools @@ -118,6 +118,12 @@ rm -rf %{buildroot} ################################################################################ %changelog +* Wed Dec 06 2023 Anton Novojilov - 3.2.0-0 +- [cli] Added '-P'/'--pager' option to use pager for long output of versions +- [cli|gen|clone] Improve verbose version info +- [cli|gen|clone] Code refactoring +- Dependencies update + * Tue Oct 17 2023 Anton Novojilov - 3.1.2-0 - [gen] Improved alias and eol info handling - [cli|gen|clone] Improve verbose version info diff --git a/gen/gen.go b/gen/gen.go index 5d4ee5a..ba66ca2 100644 --- a/gen/gen.go +++ b/gen/gen.go @@ -24,6 +24,7 @@ import ( "github.com/essentialkaos/ek/v12/path" "github.com/essentialkaos/ek/v12/sortutil" "github.com/essentialkaos/ek/v12/strutil" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/ek/v12/timeutil" "github.com/essentialkaos/ek/v12/usage" "github.com/essentialkaos/ek/v12/usage/completion/bash" @@ -40,7 +41,7 @@ import ( // App info const ( APP = "RBInstall Gen" - VER = "3.1.0" + VER = "3.2.0" DESC = "Utility for generating RBInstall index" ) @@ -149,24 +150,11 @@ func Run(gitRev string, gomod []byte) { // 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") == "" { + if !fmtc.IsColorsSupported() { fmtc.DisableColors = true } - if os.Getenv("NO_COLOR") != "" { + if !tty.IsTTY() { fmtc.DisableColors = true } } @@ -179,11 +167,11 @@ func configureUI() { switch { case fmtc.IsTrueColorSupported(): - colorTagApp, colorTagVer = "{#CC1E2C}", "{#CC1E2C}" + colorTagApp, colorTagVer = "{*}{#CC1E2C}", "{#CC1E2C}" case fmtc.Is256ColorsSupported(): - colorTagApp, colorTagVer = "{#160}", "{#160}" + colorTagApp, colorTagVer = "{*}{#160}", "{#160}" default: - colorTagApp, colorTagVer = "{r}", "{r}" + colorTagApp, colorTagVer = "{*}{r}", "{r}" } } @@ -580,7 +568,7 @@ func printMan() { func genUsage() *usage.Info { info := usage.NewInfo("", "dir") - info.AppNameColorTag = "{*}" + colorTagApp + info.AppNameColorTag = colorTagApp info.AddOption(OPT_OUTPUT, "Custom index output {s-}(default: index.json){!}", "file") info.AddOption(OPT_EOL, "File with EOL information {s-}(default: eol.json){!}", "file") @@ -611,9 +599,6 @@ func genAbout(gitRev string) *usage.About { Year: 2006, Owner: "ESSENTIAL KAOS", License: "Apache License, Version 2.0 ", - - AppNameColorTag: "{*}" + colorTagApp, - VersionColorTag: colorTagVer, } if gitRev != "" { diff --git a/go.mod b/go.mod index 556bc10..42982f7 100644 --- a/go.mod +++ b/go.mod @@ -4,13 +4,13 @@ go 1.18 require ( github.com/essentialkaos/depsy v1.1.0 - github.com/essentialkaos/ek/v12 v12.82.0 + github.com/essentialkaos/ek/v12 v12.90.1 github.com/essentialkaos/npck v1.6.1 ) require ( github.com/essentialkaos/go-linenoise/v3 v3.4.0 // indirect github.com/klauspost/compress v1.17.1 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/sys v0.13.0 // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/sys v0.15.0 // indirect ) diff --git a/go.sum b/go.sum index 705dc58..d2b838e 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,8 @@ github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk= github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI= github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8= -github.com/essentialkaos/ek/v12 v12.82.0 h1:8JqG7E1RWhMJq2CuSV0oaR96pmEjngLPG3cnJ++EJeQ= -github.com/essentialkaos/ek/v12 v12.82.0/go.mod h1:X0gkyjBCP4QiD+sV4D52aquLDLGUmHteMEL7Rsgbev0= +github.com/essentialkaos/ek/v12 v12.90.1 h1:ID950cnz4xgpqqFzhleP5xaVoLnPwuiykdH3FrogD/E= +github.com/essentialkaos/ek/v12 v12.90.1/go.mod h1:9efMqo1S8EtYhmeelOSTmMQDGC2vRgPkjkKKfvUD2eU= github.com/essentialkaos/go-linenoise/v3 v3.4.0 h1:g72w8x+/HIwOMBVvNaPYp+wMWVHrYZwzFAF7OfZR5Ts= github.com/essentialkaos/go-linenoise/v3 v3.4.0/go.mod h1:t1kNLY2bSMQCy1JXOefD2BDLs/TTPMtTv3DFNV5uDSI= github.com/essentialkaos/npck v1.6.1 h1:cFhLRRFNbl7tBXQD2+EkzTHy6y7+oxfvwsVgbhaFvUg= @@ -11,8 +11,8 @@ github.com/klauspost/compress v1.17.1 h1:NE3C767s2ak2bweCZo3+rdP4U/HoyVXLv/X9f2g github.com/klauspost/compress v1.17.1/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= 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.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +github.com/rogpeppe/go-internal v1.11.0 h1:cWPaGQEPrBb5/AsnsZesgZZ9yb1OQ+GOISoDNXVBh4M= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= diff --git a/support/support.go b/support/support.go index 7ebfd40..2b05545 100644 --- a/support/support.go +++ b/support/support.go @@ -11,6 +11,7 @@ import ( "fmt" "os" "runtime" + "runtime/debug" "strings" "github.com/essentialkaos/ek/v12/fmtc" @@ -107,6 +108,23 @@ func showDepsInfo(gomod []byte) { } } +// extractGitRevFromBuildInfo extracts git SHA from embedded build info +func extractGitRevFromBuildInfo() string { + info, ok := debug.ReadBuildInfo() + + if !ok { + return "" + } + + for _, s := range info.Settings { + if s.Key == "vcs.revision" && len(s.Value) > 7 { + return s.Value[:7] + } + } + + return "" +} + // getHashColorBullet return bullet with color from hash func getHashColorBullet(v string) string { if len(v) > 6 {