Initial cut

This commit is contained in:
Naveen Gogineni
2022-09-20 08:01:14 -04:00
parent f37b9d9b60
commit d5947d7814
8 changed files with 243 additions and 379 deletions

View File

@@ -683,24 +683,6 @@ func TestApp_RunAsSubcommandParseFlags(t *testing.T) {
expect(t, cCtx.String("lang"), "spanish")
}
func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {
a := App{
Name: "cmd",
Flags: []Flag{
&StringFlag{Name: "foo"},
},
Writer: bytes.NewBufferString(""),
}
set := flag.NewFlagSet("", flag.ContinueOnError)
_ = set.Parse([]string{"", "-bar"})
c := &Context{flagSet: set}
err := a.RunAsSubcommand(c)
expect(t, err.Error(), "flag provided but not defined: -bar")
}
func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
var parsedOption string
var args Args
@@ -1547,6 +1529,9 @@ func TestRequiredFlagAppRunBehavior(t *testing.T) {
Subcommands: []*Command{{
Name: "mySubCommand",
Flags: []Flag{&StringFlag{Name: "requiredFlag", Required: true}},
Action: func(c *Context) error {
return nil
},
}},
}},
},
@@ -1916,7 +1901,6 @@ func TestApp_Run_CommandHelpName(t *testing.T) {
}
cmd := &Command{
Name: "foo",
HelpName: "custom",
Description: "foo commands",
Subcommands: []*Command{subCmd},
}
@@ -2036,7 +2020,7 @@ func TestApp_Run_Help(t *testing.T) {
}
err := app.Run(tt.helpArguments)
if err != nil && err.Error() != tt.wantErr.Error() {
if err != nil && tt.wantErr != nil && err.Error() != tt.wantErr.Error() {
t.Errorf("want err: %s, did note %s\n", tt.wantErr, err)
}