Update Cobra and pflag, and use built-in --version feature#1069
Merged
vieux merged 3 commits intodocker:masterfrom May 21, 2018
Merged
Update Cobra and pflag, and use built-in --version feature#1069vieux merged 3 commits intodocker:masterfrom
vieux merged 3 commits intodocker:masterfrom
Conversation
thaJeztah
commented
May 18, 2018
| rootCmd.SetHelpTemplate(helpTemplate) | ||
| rootCmd.SetFlagErrorFunc(FlagErrorFunc) | ||
| rootCmd.SetHelpCommand(helpCommand) | ||
| rootCmd.SetVersionTemplate("Docker version {{.Version}}\n") |
Member
Author
There was a problem hiding this comment.
Wasn't sure if we needed this; without this, docker will be printed lowercase (i.e., name of the binary). If we think that's ok, I can remove this
thaJeztah
commented
May 18, 2018
|
|
||
| flags = cmd.Flags() | ||
| flags.BoolVarP(&opts.Version, "version", "v", false, "Print version information and quit") | ||
| flags.BoolP("version", "v", false, "Print version information and quit") |
Member
Author
There was a problem hiding this comment.
Unfortunately still needed; our flag-description has a short-hand (-v), and looks like;
-v, --version Print version information and quit
Whereas the built-in flag for Cobra doesn't have a shorthand, and looks like this;
--version version for docker
Use a tagged release of Cobra Relevant changes: - spf13/cobra#567 Add `CalledAs` method to cobra.Command - spf13/cobra#580 Update error message for missing required flags - spf13/cobra#584 Add support for --version flag - spf13/cobra#614 If user has a project in symlink, just use its destination folder and work there - spf13/cobra#649 terminates the flags when -- is found in commandline - spf13/cobra#662 Add support for ignoring parse errors - spf13/cobra#686 doc: hide hidden parent flags Also various improvements were added for generating Bash completion scripts (currently not used by us) Bump spf13/pflag to v1.0.1 Relevant changes: - spf13/pflag#122 DurationSlice: implementation and tests - spf13/pflag#115 Implement BytesHex type of argument - spf13/pflag#150 Add uintSlice and boolSlice to name prettifier - spf13/pflag#155 Add multiline wrapping support - spf13/pflag#158 doc: clarify difference between string slice vs. array - spf13/pflag#160 add ability to ignore unknown flags - spf13/pflag#163 Allow Users To Show Deprecated Flags Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This patch hides the [flags] in the usage output of commands, using the new `.DisableFlagsInUseLine` option, instead of the temporary workaround added in 8e600e1 Before this change: docker run "docker run" requires at least 1 argument. See 'docker run --help'. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] [flags] Run a command in a new container After this change: docker run "docker run" requires at least 1 argument. See 'docker run --help'. Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...] Run a command in a new container Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
812c492 to
00d0802
Compare
dnephin
approved these changes
May 19, 2018
This was referenced Nov 29, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates cobra and pflag to tagged releases, and uses the new built-in
--versionfeature.Also hides
[flags]in the usage output of commands, using the new.DisableFlagsInUseLineoption, instead of the temporary workaround added in 8e600e1 (#642)Before this change:
After this change:
Bump spf13/cobra to v0.0.3
Use a tagged release of Cobra
spf13/cobra@34ceca5...v0.0.3
Relevant changes:
CalledAsmethod to cobra.Command (w/ tests) spf13/cobra#567 AddCalledAsmethod to cobra.CommandAlso various improvements were added for generating Bash
completion scripts (currently not used by us)
Bump spf13/pflag to v1.0.1
Use a tagged release of this package
spf13/pflag@97afa5e...v1.0.1
Relevant changes: