chore(cli): handle help command manually to exit 0

This commit is contained in:
technofab 2025-06-13 15:25:08 +02:00
parent e8da91ad27
commit 4a8ccdf34c
No known key found for this signature in database

View file

@ -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.")
}