diff --git a/action/auxi.go b/action/auxi.go index 5acb0061..cbf3ce12 100644 --- a/action/auxi.go +++ b/action/auxi.go @@ -101,11 +101,11 @@ func (c *OutputContainer) Tail(lines int) string { } if line == lines { - return strings.TrimRight(string(data[i+1:]), " \n\r") + return strings.Trim(string(data[i+1:]), " \n\r") } } - return strings.TrimRight(string(data), " \n\r") + return strings.Trim(string(data), " \n\r") } // IsEmpty returns true if container is empty diff --git a/cli/cli.go b/cli/cli.go index 92eac1fd..eef4e5b7 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -18,7 +18,6 @@ import ( "github.com/essentialkaos/ek/v12/fmtutil/panel" "github.com/essentialkaos/ek/v12/fmtutil/table" "github.com/essentialkaos/ek/v12/fsutil" - "github.com/essentialkaos/ek/v12/mathutil" "github.com/essentialkaos/ek/v12/options" "github.com/essentialkaos/ek/v12/req" "github.com/essentialkaos/ek/v12/strutil" @@ -81,7 +80,7 @@ var optMap = options.Map{ OPT_LIST_PACKAGES_FLAT: {Type: options.BOOL}, OPT_VARIABLES: {Type: options.BOOL}, OPT_BARCODE: {Type: options.BOOL}, - OPT_EXTRA: {Type: options.MIXED}, + OPT_EXTRA: {Type: options.INT, Value: 10, Min: 1, Max: 256}, OPT_TIME: {Type: options.BOOL}, OPT_FORMAT: {}, OPT_DIR: {}, @@ -278,13 +277,10 @@ func process(file string) { cfg := &executor.Config{ Quiet: options.GetB(OPT_QUIET), DisableCleanup: options.GetB(OPT_NO_CLEANUP), + DebugLines: options.GetI(OPT_EXTRA), ErrsDir: errDir, } - if options.GetB(OPT_EXTRA) { - cfg.DebugLines = mathutil.Max(10, options.GetI(OPT_EXTRA)) - } - e := executor.NewExecutor(cfg) tags := strutil.Fields(options.GetS(OPT_TAG)) @@ -454,7 +450,7 @@ func genUsage() *usage.Info { info.AppNameColorTag = "{*}" + colorTagApp info.AddOption(OPT_DRY_RUN, "Parse and validate recipe") - info.AddOption(OPT_EXTRA, "Print the last lines from command output if action was failed", "?lines") + info.AddOption(OPT_EXTRA, "Number of output lines for failed action {s-}(default: 10){!}", "lines") info.AddOption(OPT_LIST_PACKAGES, "List required packages") info.AddOption(OPT_LIST_PACKAGES_FLAT, "List required packages in one line {s-}(useful for scripts){!}") info.AddOption(OPT_VARIABLES, "List recipe variables") diff --git a/cli/executor/executor.go b/cli/executor/executor.go index f6df57fa..02b0c1b1 100644 --- a/cli/executor/executor.go +++ b/cli/executor/executor.go @@ -314,7 +314,7 @@ func runCommand(e *Executor, rr render.Renderer, c *recipe.Command) bool { } if err != nil { - if !e.config.Quiet && e.config.DebugLines > 0 && cmdEnv != nil && !cmdEnv.output.IsEmpty() { + if !e.config.Quiet && cmdEnv != nil && !cmdEnv.output.IsEmpty() { fmtc.NewLine() panel.Panel( "☴ OUTPUT", "{y}",