diff --git a/Makefile b/Makefile index d48c38e8..4c9834a7 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) @@ -61,7 +62,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 @@ -105,6 +106,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/action/template.go b/action/template.go index ce4b4468..8cd6a72f 100644 --- a/action/template.go +++ b/action/template.go @@ -72,7 +72,7 @@ func Template(action *recipe.Action) error { tmplData, err := os.ReadFile(source) if err != nil { - fmt.Errorf("Can't read template %q: %v", source, err) + return fmt.Errorf("Can't read template %q: %v", source, err) } tmpl, err := template.New("").Parse(string(tmplData)) diff --git a/cli/cli.go b/cli/cli.go index 06aefd84..576e5d17 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -21,6 +21,7 @@ import ( "github.com/essentialkaos/ek/v12/options" "github.com/essentialkaos/ek/v12/req" "github.com/essentialkaos/ek/v12/strutil" + "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" @@ -40,7 +41,7 @@ import ( // Application info const ( APP = "bibop" - VER = "8.0.1" + VER = "8.0.2" DESC = "Utility for testing command-line tools" ) @@ -101,8 +102,7 @@ var optMap = options.Map{ OPT_GENERATE_MAN: {Type: options.BOOL}, } -var colorTagApp string -var colorTagVer string +var colorTagApp, colorTagVer string var rawOutput bool // ////////////////////////////////////////////////////////////////////////////////// // @@ -144,23 +144,7 @@ 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 - } - } - - // Check for output redirect using pipes - if fsutil.IsCharacterDevice("/dev/stdin") && - !fsutil.IsCharacterDevice("/dev/stdout") && - os.Getenv("FAKETTY") == "" { + if !tty.IsTTY() { fmtc.DisableColors = true rawOutput = true } @@ -171,17 +155,13 @@ func preConfigureUI() { fmtc.DisableColors = false } - if os.Getenv("NO_COLOR") != "" { - fmtc.DisableColors = true - } - switch { case fmtc.IsTrueColorSupported(): - colorTagApp, colorTagVer = "{#66CC99}", "{#66CC99}" + colorTagApp, colorTagVer = "{*}{#66CC99}", "{#66CC99}" case fmtc.Is256ColorsSupported(): - colorTagApp, colorTagVer = "{#85}", "{#85}" + colorTagApp, colorTagVer = "{*}{#85}", "{#85}" default: - colorTagApp, colorTagVer = "{c}", "{c}" + colorTagApp, colorTagVer = "{*}{c}", "{c}" } fmtutil.SeparatorTitleColorTag = colorTagApp @@ -407,15 +387,6 @@ func printError(f string, a ...interface{}) { } } -// printError prints warning message to console -func printWarn(f string, a ...interface{}) { - if len(a) == 0 { - fmtc.Fprintln(os.Stderr, "{y}"+f+"{!}") - } else { - 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...) @@ -451,7 +422,7 @@ func printMan() { func genUsage() *usage.Info { info := usage.NewInfo("", "recipe") - info.AppNameColorTag = "{*}" + colorTagApp + info.AppNameColorTag = colorTagApp info.AddOption(OPT_DRY_RUN, "Parse and validate recipe") info.AddOption(OPT_EXTRA, "Number of output lines for failed action {s-}(default: 10){!}", "lines") @@ -520,8 +491,9 @@ func genAbout(gitRev string) *usage.About { Year: 2006, Owner: "ESSENTIAL KAOS", - AppNameColorTag: "{*}" + colorTagApp, + AppNameColorTag: colorTagApp, VersionColorTag: colorTagVer, + DescSeparator: "{s}—{!}", License: "Apache License, Version 2.0 ", BugTracker: "https://github.com/essentialkaos/bibop/issues", diff --git a/render/renderer_terminal.go b/render/renderer_terminal.go index 8cb508f7..6432a546 100644 --- a/render/renderer_terminal.go +++ b/render/renderer_terminal.go @@ -17,7 +17,7 @@ import ( "github.com/essentialkaos/ek/v12/fmtc" "github.com/essentialkaos/ek/v12/fmtutil" "github.com/essentialkaos/ek/v12/strutil" - "github.com/essentialkaos/ek/v12/terminal/window" + "github.com/essentialkaos/ek/v12/terminal/tty" "github.com/essentialkaos/bibop/recipe" ) @@ -252,7 +252,7 @@ func (rr *TerminalRenderer) renderTmpMessage(f string, a ...interface{}) { return } - ww := window.GetWidth() + ww := tty.GetWidth() if ww <= 0 { fmtc.TPrintf(f, a...) @@ -313,7 +313,7 @@ func (rr *TerminalRenderer) renderCurrentActionProgress() { // renderMessage prints message limited by window size func (rr *TerminalRenderer) renderMessage(f string, a ...interface{}) { - ww := window.GetWidth() + ww := tty.GetWidth() if ww <= 0 { fmtc.Printf(f, a...)