cli args moved from Init() to Parse()

This commit is contained in:
2026-03-19 09:10:49 +01:00
parent 00b84278d8
commit 20b6b961fb
4 changed files with 41 additions and 49 deletions
+6 -6
View File
@@ -26,8 +26,8 @@ func TestOneOptWithEqual(t *testing.T) {
"--color=blue",
}
cli.Init(args, "1.0.0", "TestOneOptWithEqual description")
if err := cli.Parse(); err != nil {
cli.Init("1.0.0", "TestOneOptWithEqual description")
if err := cli.Parse(args); err != nil {
t.Error(err)
} else if color != "blue" {
t.Errorf("Expected color blue, got %q", color)
@@ -54,8 +54,8 @@ func testIntArrayOptOk(t *testing.T, n int, args []string, flags ...int16) {
var cli CliParser
t.Logf("Arg set n. %d", n)
addBoxOption(&cli, &box)
cli.Init(args, "1.0.0", "TestIntArrayOpt description", flags...)
if err := cli.Parse(); err != nil {
cli.Init("1.0.0", "TestIntArrayOpt description", flags...)
if err := cli.Parse(args); err != nil {
t.Error(err)
} else if len(box) != 4 {
t.Errorf(`Expected 4 items, got %d`, len(box))
@@ -67,8 +67,8 @@ func testIntArrayOptKo(t *testing.T, n int, args []string, msg string, flags ...
var cli CliParser
t.Logf("Arg set n. %d", n)
addBoxOption(&cli, &box)
cli.Init(args, "1.0.0", "TestIntArrayOpt description", flags...)
if err := cli.Parse(); err == nil {
cli.Init("1.0.0", "TestIntArrayOpt description", flags...)
if err := cli.Parse(args); err == nil {
t.Errorf("Expected error, got nil")
} else if err.Error() != msg {
t.Errorf(`Invalid error: %q; expected: %q`, err.Error(), msg)