Skip to content
Myr

Add README section for RemoveCommand

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Étienne Vallette d'Osia · committed by Étienne Vallette d'Osia · parent fd2b84c · Browse files · 1 file+9 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−0 removed

  • other:+9 added−0 removed

1 file+9 added−0 removed

modified:README.md+9 added
141 unmodified lines
142A flag can also be assigned locally which will only apply to that specific command.143144 HugoCmd.Flags().StringVarP(&Source, "source", "s", "", "Source directory to read from")145146### Remove a command from its parent147148Removing a command is not a common action is simple program but it allows 3rd parties to customize an existing command tree.149150In this exemple, we remove the existing `VersionCmd` command of an existing root command, and we replace it by our own version.151152 mainlib.RootCmd.RemoveCommand(mainlib.VersionCmd)153 mainlib.RootCmd.AddCommand(versionCmd)154155### Once all commands and flags are defined, Execute the commands156157Execute should be run on the root for clarity, though it can be called on any command.158
250 unmodified lines