/
center_download.go
42 lines (34 loc) · 1.03 KB
/
center_download.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package cmd
import (
"log"
"net/http"
"github.com/jenkins-zh/jenkins-cli/client"
"github.com/spf13/cobra"
)
// CenterDownloadOption as the options of download command
type CenterDownloadOption struct {
LTS bool
Output string
RoundTripper http.RoundTripper
}
var centerDownloadOption CenterDownloadOption
func init() {
centerCmd.AddCommand(centerDownloadCmd)
centerDownloadCmd.Flags().BoolVarP(¢erDownloadOption.LTS, "lts", "", true, "If you want to download Jenkins as LTS")
centerDownloadCmd.Flags().StringVarP(¢erDownloadOption.Output, "output", "o", "jenkins.war", "The file of output")
}
var centerDownloadCmd = &cobra.Command{
Use: "download",
Short: "Download Jenkins",
Long: `Download Jenkins`,
Run: func(_ *cobra.Command, _ []string) {
jclient := &client.UpdateCenterManager{
JenkinsCore: client.JenkinsCore{
RoundTripper: centerDownloadOption.RoundTripper,
},
}
if err := jclient.DownloadJenkins(centerDownloadOption.LTS, centerDownloadOption.Output); err != nil {
log.Fatal(err)
}
},
}