-
Notifications
You must be signed in to change notification settings - Fork 30
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
Remove parent command's flags from subcommand usage #44
Conversation
Found this issue, too. Both on my personal programs and Jekyll. @parkr would you mind reviewing and merging this to fix the issue? |
Issue jekyll#42 introduced the ability for subcommands to print help output that includes its parent's flags. Unfortunately, this duplicated some flags, such as `-h`, `-v`, and `-t`, that are also considered to be a part of the subcommand. This makes the usage output look a bit odd, as these flags are printed twice. This commit removes that duplication; it does not print help output for flags that are also part of the parent command's flags.
44b6c7f
to
6e6f85a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the end-result but not the route proposed. Left a couple of comments to address
Thank you.
spec/command_spec.rb
Outdated
it "can tell whether it is a parent command or not" do | ||
expect(command.root?).to be true | ||
expect(command_with_parent.root?).to be false | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should ideally be testing the issue at hand (which is in Presenter
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed this test for the time being and will write a better one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take your time. Don't forget to remove Command#root?
if it no longer has a role..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added tests and removed Command#root?
.
It is more direct to just check the truthiness of Command#parent instead.
5aafdc1
to
3b4647b
Compare
7822632
to
e80351f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @mdippery
@jekyllbot: merge +minor |
A change related to #42 allowed subcommands to inherit flags from their parent. Unfortunately, this change has resulted in some duplication of flags. As shown in the example above, the flags
-h
,-v
, and-t
were printed twice in the help output when help for subcommands are shown, which is unexpected and looks a bit odd. It's especially pronounced in subcommands in which the parent command does not have any flags; two blocks for-h
,-v
, and-t
are printed consecutively now, like this:This change corrects that so that flags for subcommands are only printed once.