Skip to content

Commit d3f44c0

Browse files
committed
feat: 新增显示当前版本的命令
1 parent 6d906bc commit d3f44c0

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

cmd/root.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ func CreateRootCmd() *cobra.Command {
3232
rootCmd.AddCommand(CreateLogCmd())
3333
rootCmd.AddCommand(CreateCheckUpdateCmd())
3434
rootCmd.AddCommand(CreateUpdateCmd())
35+
rootCmd.AddCommand(CreateVersionCmd())
3536

3637
// 全局标志
3738
rootCmd.PersistentFlags().StringVarP(&ConfigFile, "config", "c", "config.yaml", "配置文件路径")

cmd/version.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package cmd
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/https-cert/deploy/internal/config"
7+
"github.com/spf13/cobra"
8+
)
9+
10+
// CreateVersionCmd 创建版本命令
11+
func CreateVersionCmd() *cobra.Command {
12+
return &cobra.Command{
13+
Use: "version",
14+
Short: "显示当前版本",
15+
Long: "显示 anssl CLI 的当前版本号",
16+
Run: func(cmd *cobra.Command, args []string) {
17+
fmt.Printf("anssl %s\n", config.Version)
18+
},
19+
}
20+
}
21+

0 commit comments

Comments
 (0)