// PluginOptions contains the command line options
typePluginOptionsstruct{
OutputOption
Uploadbool
CheckUpdatebool
Openbool
...
...
@@ -35,14 +36,14 @@ type PluginOptions struct {
funcinit(){
rootCmd.AddCommand(pluginCmd)
pluginCmd.PersistentFlags().BoolVarP(&pluginOpt.Upload,"upload","u",false,"Upload plugin to your Jenkins server")
pluginCmd.PersistentFlags().BoolVarP(&pluginOpt.CheckUpdate,"check","c",false,"Checkout update center server")
pluginCmd.PersistentFlags().BoolVarP(&pluginOpt.Open,"open","o",false,"Open the browse with the address of plugin manager")
pluginCmd.PersistentFlags().BoolVarP(&pluginOpt.List,"list","l",false,"Print all the plugins which are installed")
pluginCmd.PersistentFlags().StringArrayVarP(&pluginOpt.Install,"install","",[]string{},"Install a plugin by shortName")
pluginCmd.PersistentFlags().StringVarP(&pluginOpt.Uninstall,"uninstall","","","Uninstall a plugin by shortName")
pluginCmd.PersistentFlags().StringArrayVarP(&pluginOpt.Filter,"filter","",[]string{},"Filter for the list, like: active, hasUpdate, downgradable, enable, name=foo")
pluginCmd.Flags().BoolVarP(&pluginOpt.Upload,"upload","u",false,"Upload plugin to your Jenkins server")
pluginCmd.Flags().BoolVarP(&pluginOpt.CheckUpdate,"check","c",false,"Checkout update center server")
pluginCmd.Flags().BoolVarP(&pluginOpt.Open,"open","o",false,"Open the browse with the address of plugin manager")
pluginCmd.Flags().BoolVarP(&pluginOpt.List,"list","l",false,"Print all the plugins which are installed")
pluginCmd.Flags().StringVarP(&pluginOpt.Format,"format","",TableOutputFormat,"Format the output")
pluginCmd.Flags().StringArrayVarP(&pluginOpt.Install,"install","",[]string{},"Install a plugin by shortName")
pluginCmd.Flags().StringVarP(&pluginOpt.Uninstall,"uninstall","","","Uninstall a plugin by shortName")
pluginCmd.Flags().StringArrayVarP(&pluginOpt.Filter,"filter","",[]string{},"Filter for the list, like: active, hasUpdate, downgradable, enable, name=foo")
}
varpluginOptPluginOptions
...
...
@@ -150,9 +151,8 @@ var pluginCmd = &cobra.Command{
}
ifplugins,err:=jclient.GetPlugins();err==nil{
table:=util.CreateTable(os.Stdout)
table.AddRow("number","name","version","update")
fori,plugin:=rangeplugins.Plugins{
filteredPlugins:=make([]client.Plugin,0)
for_,plugin:=rangeplugins.Plugins{
iffilter{
ifhasUpdate&&!plugin.HasUpdate{
continue
...
...
@@ -173,10 +173,18 @@ var pluginCmd = &cobra.Command{