Merge pull request #1239 from mengjiao-liu/clean-up-dup-flag

Clean up code duplicate
This commit is contained in:
Jianbo Sun
2021-03-19 16:06:16 +08:00
committed by GitHub
2 changed files with 8 additions and 3 deletions
+3 -3
View File
@@ -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
}
+5
View File
@@ -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")
}