mirror of
https://gitlab.com/TECHNOFAB/nixtest.git
synced 2025-12-12 02:00:18 +01:00
chore(cli): handle help command manually to exit 0
This commit is contained in:
parent
e8da91ad27
commit
4a8ccdf34c
1 changed files with 10 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
|
||||||
"github.com/jedib0t/go-pretty/v6/text"
|
"github.com/jedib0t/go-pretty/v6/text"
|
||||||
"github.com/rs/zerolog/log"
|
"github.com/rs/zerolog/log"
|
||||||
flag "github.com/spf13/pflag"
|
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.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.PureEnv, "pure", false, "Unset all env vars before running script tests")
|
||||||
flag.BoolVar(&cfg.NoColor, "no-color", false, "Disable coloring")
|
flag.BoolVar(&cfg.NoColor, "no-color", false, "Disable coloring")
|
||||||
|
helpRequested := flag.BoolP("help", "h", false, "Show this menu")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *helpRequested {
|
||||||
|
fmt.Println("Usage of nixtest:")
|
||||||
|
flag.PrintDefaults()
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
if cfg.TestsFile == "" {
|
if cfg.TestsFile == "" {
|
||||||
log.Panic().Msg("Tests file path (-f or --tests) is required.")
|
log.Panic().Msg("Tests file path (-f or --tests) is required.")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue