diff --git a/references/cli/capability.go b/references/cli/capability.go index 0535f1056..3d9030a08 100644 --- a/references/cli/capability.go +++ b/references/cli/capability.go @@ -73,7 +73,7 @@ func NewCapCenterConfigCommand(ioStreams cmdutil.IOStreams) *cobra.Command { return nil }, } - cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token") + AddTokenVarFlags(cmd) return cmd } @@ -107,7 +107,7 @@ func NewCapInstallCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Comm return nil }, } - cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token") + AddTokenVarFlags(cmd) return cmd } @@ -144,7 +144,7 @@ func NewCapUninstallCommand(c types.Args, ioStreams cmdutil.IOStreams) *cobra.Co return common.RemoveCapability(env.Namespace, c, newClient, name, ioStreams) }, } - cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token") + AddTokenVarFlags(cmd) return cmd } diff --git a/references/cli/help.go b/references/cli/help.go index d90c7a0cb..d318a7a87 100644 --- a/references/cli/help.go +++ b/references/cli/help.go @@ -47,3 +47,8 @@ func PrintHelpByTag(cmd *cobra.Command, all []*cobra.Command, tag string) { cmd.Println(table.String()) cmd.Println() } + +// AddTokenVarFlags adds token flag to a command +func AddTokenVarFlags(cmd *cobra.Command) { + cmd.PersistentFlags().StringP("token", "t", "", "Github Repo token") +}