-
Notifications
You must be signed in to change notification settings - Fork 328
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
Add built-in support for --version flag #102
Conversation
@griffin-stewie What do you think of this design? |
@natecook1000 Thank you for adding built-in support for version flag. It looks great. One thing I noticed is that the information about the version flag is not printed in the OPTIONS section of the help. I felt it would have been nice to have a help message output to make it more end-user friendly. You don't support short names like |
cbaaf55
to
4e5dd28
Compare
4e5dd28
to
e13cfda
Compare
Great points, @griffin-stewie! I've added the flag to the generated help, but I'm holding off for now on customizing the flag. There might be a more general pattern for customizing these built-in options, which I'd like to look at after getting code-completion support built. |
I agree with you. Thank you for implementing it. |
This is awesome. Thanks! |
Use the built-in version support from Swift ArgumentParser: apple/swift-argument-parser#102
Use the built-in version support from Swift ArgumentParser: apple/swift-argument-parser#102
Description
Adds built-in support for responding to a
--version
flag. This flag is only valid when a command provides aversion:
parameter in its configuration. Fixes #25.Detailed Design
If a command in the tree has specified a version, the
--version
flag is checked for only after evaluating any explicitly defined arguments. This allows commands to define their own--version
flags or options and not have them be overridden by the auto-generated version.Nested commands inherit their version from their parent commands, and can override their parent by providing their own version string.
version
is added to theCommandConfiguration
type and to the initializer:Documentation Plan
How has the new feature been documented? Have the relevant portions of the guide been updated in addition to symbol-level documentation?
Test Plan
--version
get that behavior.Math
.Source Impact
Because the
version:
parameter is defaulted, this has no source impact. In addition, since there's no change in behavior unless the command defines a version, there's no impact on existing tools' behavior.Checklist