-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcipher.go
More file actions
63 lines (56 loc) · 1.47 KB
/
cipher.go
File metadata and controls
63 lines (56 loc) · 1.47 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
package main
import (
"fmt"
"github.com/spf13/cobra"
"os"
)
var (
RootCmd = &cobra.Command{
Use: `cipher [OPTIONS] COMMAND [arg...]`,
Short: "cipher commands",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(cmd.UsageString())
},
}
)
func cli() {
RootCmd.PersistentFlags().BoolVarP(&agridCli.verbose, "verbose", "v", false, `Verbose output`)
cobra.OnInitialize(func() {
if err := agridCli.init(); err != nil {
fmt.Printf("Init error: %v\n", err)
os.Exit(1)
}
})
// versionCmd represents the agrid version
versionCmd := &cobra.Command{
Use: "version",
Short: "Display the version number of cipher",
Long: `Display the version number of cipher`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("cipher version: %s, build: %s)\n", Version, Build)
},
}
RootCmd.AddCommand(versionCmd)
// infoCmd represents the agrid information
infoCmd := &cobra.Command{
Use: "info",
Short: "Display agrid version and server information",
Long: `Display agrid version and server information.`,
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("agrid version: %s, build: %s)\n", Version, Build)
fmt.Printf("Server: %s\n", config.serverAddress)
},
}
RootCmd.AddCommand(infoCmd)
//Execute commad
cmd, _, err := RootCmd.Find(os.Args[1:])
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if err := cmd.Execute(); err != nil {
fmt.Printf("Error during: %s: %v\n", cmd.Name(), err)
os.Exit(1)
}
os.Exit(0)
}