plugin_trend.go 779 字节
Newer Older
1 2 3
package cmd

import (
4 5
	"net/http"

6
	"github.com/jenkins-zh/jenkins-cli/client"
7 8 9
	"github.com/spf13/cobra"
)

10 11 12 13 14 15 16
// PluginTreadOption is the option of plugin trend command
type PluginTreadOption struct {
	RoundTripper http.RoundTripper
}

var pluginTreadOption PluginTreadOption

17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
func init() {
	pluginCmd.AddCommand(pluginTrendCmd)
}

var pluginTrendCmd = &cobra.Command{
	Use:   "trend <pluginName>",
	Short: "Show the trend of the plugin",
	Long:  `Show the trend of the plugin`,
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			cmd.Help()
			return
		}

		pluginName := args[0]

33 34 35 36 37 38
		jclient := &client.PluginAPI{
			RoundTripper: pluginTreadOption.RoundTripper,
		}
		if tread, err := jclient.ShowTrend(pluginName); err == nil {
			cmd.Print(tread)
		}
39 40
	},
}