提交 5dac31cb 编写于 作者: Y Yanjun Shi 提交者: LinuxSuRen

Add support to add description for the jcli config item (#101)

* Add support to add description for the jcli config item

* fix error

* delete useless information
上级 3a614a3b
......@@ -28,7 +28,11 @@ var configCmd = &cobra.Command{
Long: `Manage the config of jcli`,
Run: func(cmd *cobra.Command, args []string) {
current := getCurrentJenkins()
fmt.Printf("Current Jenkins's name is %s, url is %s\n", current.Name, current.URL)
if current.Description != "" {
fmt.Printf("Current Jenkins's name is %s, url is %s, description is %s\n", current.Name, current.URL, current.Description)
} else {
fmt.Printf("Current Jenkins's name is %s, url is %s\n", current.Name, current.URL)
}
},
Example: ` jcli config generate
jcli config list
......@@ -37,12 +41,13 @@ var configCmd = &cobra.Command{
// JenkinsServer holds the configuration of your Jenkins
type JenkinsServer struct {
Name string `yaml:"name"`
URL string `yaml:"url"`
UserName string `yaml:"username"`
Token string `yaml:"token"`
Proxy string `yaml:"proxy"`
ProxyAuth string `yaml:"proxyAuth"`
Name string `yaml:"name"`
URL string `yaml:"url"`
UserName string `yaml:"username"`
Token string `yaml:"token"`
Proxy string `yaml:"proxy"`
ProxyAuth string `yaml:"proxyAuth"`
Description string `yaml:"description"`
}
type Config struct {
......
......@@ -21,6 +21,7 @@ func init() {
configAddCmd.Flags().StringVarP(&configAddOptions.Token, "token", "t", "", "Token of the Jenkins")
configAddCmd.Flags().StringVarP(&configAddOptions.Proxy, "proxy", "p", "", "Proxy of the Jenkins")
configAddCmd.Flags().StringVarP(&configAddOptions.ProxyAuth, "proxyAuth", "a", "", "ProxyAuth of the Jenkins")
configAddCmd.Flags().StringVarP(&configAddOptions.Description, "description", "d", "", "Description of the Jenkins")
}
var configAddCmd = &cobra.Command{
......
......@@ -20,13 +20,17 @@ var configListCmd = &cobra.Command{
current := getCurrentJenkins()
table := util.CreateTable(os.Stdout)
table.AddRow("number", "name", "url")
table.AddRow("number", "name", "url", "description")
for i, jenkins := range getConfig().JenkinsServers {
name := jenkins.Name
if name == current.Name {
name = fmt.Sprintf("*%s", name)
}
table.AddRow(fmt.Sprintf("%d", i), name, jenkins.URL)
if len(jenkins.Description) > 15 {
table.AddRow(fmt.Sprintf("%d", i), name, jenkins.URL, jenkins.Description[0:15])
} else {
table.AddRow(fmt.Sprintf("%d", i), name, jenkins.URL, jenkins.Description)
}
}
table.Render()
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册