-
Notifications
You must be signed in to change notification settings - Fork 344
Exclude supercommands from help #300
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
Conversation
@natecook1000 ptal and let us know so @miggs597 can progress on swiftlang/swift-package-manager#3407 |
@miggs597 Thanks for working on this! After looking further, it doesn't look like this actually needs to be configurable. You'll still need to use your custom mirror to suppress |
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.
Let's make this new behavior the default for all commands — you can drop the changes to CommandConfiguration
and the documentation update, since it's really a bug that it even has the current behavior.
var commandsToShowHelp = [ParsableCommand.Type]() | ||
if let commandType = commandStack.last, !commandType.includeSuperCommandInHelp { | ||
commandsToShowHelp.append(commandType) | ||
} else { | ||
commandsToShowHelp = commandStack | ||
} |
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 be able to just grab the top of the command stack this way...
var commandsToShowHelp = [ParsableCommand.Type]() | |
if let commandType = commandStack.last, !commandType.includeSuperCommandInHelp { | |
commandsToShowHelp.append(commandType) | |
} else { | |
commandsToShowHelp = commandStack | |
} | |
guard let commandType = commandStack.last else { | |
return [] | |
} |
...and then remove the following for
-in
loop and de-dent its contents.
@swift-ci Please test |
@swift-ci Please test |
🎉 |
@natecook1000 we would need a new tag so we can pull this fix into the toolchain build to fix the SwiftPM regression. please let us know when you have one ready! |
Currently when asking for help with a subcommand we will receive help for it, and all supercommands that precede it. I propose the ability to only print help for the subcommand. The best example of this is in SwiftPM.
Current Behavior:
Proposed Behavior
These changes are fully backwards compatible, with no changes needed to existing sources that depend on
ArgumentParser
.To access this new feature a user would just need to add
includeSuperCommandInHelp = false
to their struct that conforms toParsableCommand
Checklist