Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When subcommand must be present but not provided the error must be triggered #104

Merged
merged 1 commit into from Jul 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions command.go
Expand Up @@ -68,7 +68,13 @@ func (o *Command) parseSubCommands(args *[]string) error {
if err != nil {
return err
}
if v.happened {
return nil
}
}
// If we got here, there were subcommands to parse,
// but none were found, so return an error
return newSubCommandError(o)
}
return nil
}
Expand Down Expand Up @@ -137,7 +143,7 @@ func (o *Command) parseArguments(args *[]string) error {
// Will parse provided list of arguments
// common usage would be to pass directly os.Args
func (o *Command) parse(args *[]string) error {
// If we already been parsed do nothing
// If already been parsed do nothing
if o.parsed {
return nil
}
Expand All @@ -157,7 +163,7 @@ func (o *Command) parse(args *[]string) error {
}
}

// Set happened status to true when command happend
// Set happened status to true when command happened
o.happened = true

// Reduce arguments by removing Command name
Expand Down