Skip to content

Commit 2f0db75

Browse files
committed
feat: add upgrade subcmd
1 parent 0aeffb4 commit 2f0db75

File tree

6 files changed

+79
-71
lines changed

6 files changed

+79
-71
lines changed

README.md

+5
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,8 @@ ergo install k8s
3636
```
3737

3838
具体参数可以参考docs部分
39+
40+
41+
## 1.x 版本计划
42+
43+
- [ ] 优化分类子命令

cmd/upgrade.go

+47
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// MIT License
2+
// Copyright (c) 2019 ysicing <i@ysicing.me>
3+
4+
package cmd
5+
6+
import (
7+
"fmt"
8+
"github.com/spf13/cobra"
9+
"github.com/wangle201210/githubapi/repos"
10+
"github.com/ysicing/go-utils/excmd"
11+
"k8s.io/klog"
12+
"runtime"
13+
)
14+
15+
var upgradeCmd = &cobra.Command{
16+
Use: "upgrade",
17+
Short: "升级ergo版本",
18+
Aliases: []string{"up"},
19+
Run: func(cmd *cobra.Command, args []string) {
20+
var pkg = repos.Pkg{"ysicing", "ergo"}
21+
lastag, _ := pkg.LastTag()
22+
if lastag.Name != Version {
23+
if runtime.GOOS != "linux" {
24+
klog.Info(excmd.RunCmdRes("/bin/zsh", "-c", "brew upgrade ysicing/tap/ergo"))
25+
} else {
26+
newbin := fmt.Sprintf("https://github.com/ysicing/ergo/releases/download/%v/ergo_linux_amd64", lastag.Name)
27+
excmd.DownloadFile(newbin, "/usr/local/bin/ergo")
28+
}
29+
}
30+
},
31+
}
32+
33+
//var uninstallCmd = &cobra.Command{
34+
// Use: "uninstall",
35+
// Short: "卸载ergo",
36+
// Run: func(cmd *cobra.Command, args []string) {
37+
// if runtime.GOOS != "linux" {
38+
// klog.Info(excmd.RunCmdRes("/bin/zsh", "-c", "brew uninstall ysicing/tap/ergo"))
39+
// } else {
40+
// klog.Info("not support. which ergo then delete it.")
41+
// }
42+
// },
43+
//}
44+
45+
func init() {
46+
rootCmd.AddCommand(upgradeCmd)
47+
}

cmd/wang.go

-43
This file was deleted.

go.mod

+5-2
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@ go 1.14
44

55
require (
66
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
7-
github.com/aliyun/alibaba-cloud-sdk-go v1.61.174 // indirect
87
github.com/aliyun/aliyun-oss-go-sdk v2.1.0+incompatible
8+
github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f // indirect
99
github.com/cuisongliu/sshcmd v1.5.2
1010
github.com/drone/drone-go v1.3.1
1111
github.com/fsnotify/fsnotify v1.4.9 // indirect
1212
github.com/ghodss/yaml v1.0.0
1313
github.com/gin-gonic/gin v1.6.3
1414
github.com/go-ole/go-ole v1.2.4 // indirect
15+
github.com/hashicorp/go-version v1.2.1 // indirect
1516
github.com/koding/logging v0.0.0-20160720134017-8b5a689ed69b // indirect
1617
github.com/koding/vagrantutil v0.0.0-20180710063911-70827343f116
1718
github.com/mitchellh/go-homedir v1.1.0
1819
github.com/mitchellh/mapstructure v1.3.3 // indirect
1920
github.com/pelletier/go-toml v1.8.0 // indirect
2021
github.com/prometheus/client_golang v1.7.1
22+
github.com/satori/go.uuid v1.2.0 // indirect
2123
github.com/shirou/gopsutil v2.20.3+incompatible
2224
github.com/sirupsen/logrus v1.4.2
2325
github.com/spf13/afero v1.3.3 // indirect
@@ -26,9 +28,10 @@ require (
2628
github.com/spf13/jwalterweatherman v1.1.0 // indirect
2729
github.com/spf13/pflag v1.0.5 // indirect
2830
github.com/spf13/viper v1.7.1
31+
github.com/wangle201210/githubapi v0.0.0-20200804144924-cde7bbdc36ab
2932
github.com/wonderivan/logger v1.0.0
3033
github.com/ysicing/ginmid v0.2.1
31-
github.com/ysicing/go-utils v0.2.5
34+
github.com/ysicing/go-utils v0.3.1
3235
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
3336
golang.org/x/sys v0.0.0-20200803210538-64077c9b5642 // indirect
3437
golang.org/x/text v0.3.3 // indirect

0 commit comments

Comments
 (0)