-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
50 lines (41 loc) · 1.1 KB
/
main.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
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"os"
"github.com/spf13/cobra"
"github.com/chinatree/dnsctl/cmd/aliyun/domain"
"github.com/chinatree/dnsctl/cmd/aliyun/group"
"github.com/chinatree/dnsctl/cmd/aliyun/record"
app "github.com/chinatree/dnsctl/internal/app/aliyun"
)
func main() {
versionCmd := &cobra.Command{
Use: "version",
Short: "版本号",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("%s v%s\n", app.Name, app.Version)
},
}
rootCmd := &cobra.Command{
Use: app.Name,
Long: fmt.Sprintf("%s is a simple command line client for aliyun dns.", app.Name),
Short: "aliyun dns command line client",
SuggestFor: []string{app.Name},
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
}
rootCmd.AddCommand(
domain.Cmd,
group.Cmd,
record.Cmd,
versionCmd,
)
rootCmd.PersistentFlags().String("region-id", "default", "区域ID")
rootCmd.PersistentFlags().String("secret-id", "", "密钥ID")
rootCmd.PersistentFlags().String("secret-key", "", "加密密钥")
if err := rootCmd.Execute(); err != nil {
panic(err)
}
os.Exit(0)
}