Skip to content

Commit

Permalink
增加版本显示
Browse files Browse the repository at this point in the history
  • Loading branch information
iiiusky committed Oct 27, 2020
1 parent 3ba05a9 commit 9204a2e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ var rootCmd = &cobra.Command{
Short: "阿里云API利用工具",
Long: `该工具主要是方便快速使用阿里云api执行一些操作`,
PersistentPreRunE: func(cmd *cobra.Command, args []string) error {
if cmd.Use == "version" {
return nil
}

if accessKey == "" || secretKey == "" {
return errors.New("请设置ak以及sk的值")
}
Expand Down
1 change: 1 addition & 0 deletions common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
var AccessKey string
var SecretKey string
var ECSRegions []ecs.Region
var APPVersion string

// 初始化区域信息表
func InitEcsRegions() bool {
Expand Down
8 changes: 6 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ limitations under the License.
*/
package main

import "alicloud-tools/cmd"
import (
"alicloud-tools/cmd"
"alicloud-tools/common"
)

func main() {
cmd.Execute()
common.APPVersion = "1.0.0"
cmd.Execute()
}

0 comments on commit 9204a2e

Please sign in to comment.