From 4a8ccdf34cff2c91bab5fa906f6ed4e6b0e928de Mon Sep 17 00:00:00 2001 From: technofab Date: Fri, 13 Jun 2025 15:25:08 +0200 Subject: [PATCH] chore(cli): handle help command manually to exit 0 --- internal/config/config.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/config/config.go b/internal/config/config.go index f0b41e6..9eef9bb 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -1,6 +1,9 @@ package config import ( + "fmt" + "os" + "github.com/jedib0t/go-pretty/v6/text" "github.com/rs/zerolog/log" flag "github.com/spf13/pflag" @@ -28,9 +31,16 @@ func Load() AppConfig { flag.StringVarP(&cfg.SkipPattern, "skip", "s", "", "Regular expression to skip tests (e.g., 'test-.*|.*-b')") flag.BoolVar(&cfg.PureEnv, "pure", false, "Unset all env vars before running script tests") flag.BoolVar(&cfg.NoColor, "no-color", false, "Disable coloring") + helpRequested := flag.BoolP("help", "h", false, "Show this menu") flag.Parse() + if *helpRequested { + fmt.Println("Usage of nixtest:") + flag.PrintDefaults() + os.Exit(0) + } + if cfg.TestsFile == "" { log.Panic().Msg("Tests file path (-f or --tests) is required.") }