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

Consider the existence of operands to build on automatic help setup #5

Closed
ibraimgm opened this issue Oct 4, 2019 · 0 comments · Fixed by #6
Closed

Consider the existence of operands to build on automatic help setup #5

ibraimgm opened this issue Oct 4, 2019 · 0 comments · Fixed by #6
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest

Comments

@ibraimgm
Copy link
Owner

ibraimgm commented Oct 4, 2019

On cmd.go the setupHelp() function has the following logic to determine if the help flags (-h and --help) should be automatically added:

if (len(cmd.optentries) > 0 || len(cmd.commands) > 0) && cmd.shortopt["-h"] == nil {
  cmd.Bool("help", "h", false, "Show this help message.")
}

Note that it checks for the existence of any flags (len(cmd.optentries) > 0) or commands (len(cmd.commands) > 0). However, it does not account for the existence of operands (cmd.operands), so when a command has no flags or commands, but has operands, the automatic help flag is not generated.

Note that this change might cause impact on some tests.

@ibraimgm ibraimgm added bug Something isn't working good first issue Good for newcomers hacktoberfest labels Oct 4, 2019
GustavoKatel added a commit to GustavoKatel/libcmd that referenced this issue Oct 4, 2019
Fixes ibraimgm#5

Signed-off-by: Gustavo Sampaio <gbritosampaio@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers hacktoberfest
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant