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

Do not skip groups that are commands when working out alignment #281

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

chipaca
Copy link
Contributor

@chipaca chipaca commented Oct 10, 2018

Without this change, groups that are commands but that don't satisfy
(*Group).showInHelp() would be skipped when working out the alignment,
which would result in negative lengths when trying to process a group
with only positional options.

This fixes #280.

Without this change, groups that are commands but that don't satisfy
(*Group).showInHelp() would be skipped when working out the alignment,
which would result in negative lengths when trying to process a group
with only positional options.

This fixes jessevdk#280.
@chipaca
Copy link
Contributor Author

chipaca commented Oct 10, 2018

I need to say: I'm not really sure this is the right fix. It still leaves the help looking weird in some combinations (like if you have a hidden command that is the one you're asking for help on). Nevertheless it fixes the issue, and I don't think it introduces more issues...

"No error": {value: nil, isHelp: false},
"Plain error": {value: errors.New("an error"), isHelp: false},
"ErrUnknown": {value: newError(ErrUnknown, "an error"), isHelp: false},
"ErrHelp": {value: newError(ErrHelp, "an error"), isHelp: true},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gah, my gofmt-on-save is forever doing this

@sammiq
Copy link

sammiq commented Aug 10, 2019

if you just want to simply fix skipping the group, why not just change !grp.showInHelp() to grp.Hidden. The problem occurs because there are no options in the group so grp.showInHelp() returns false. The presence of options being hidden is checked below the argument check anyway.

This is what I implemented on my fork here: https://github.com/sammiq/go-flags/pull/3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using only positional arguments panics
2 participants