Skip to content

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