-
Notifications
You must be signed in to change notification settings - Fork 5
/
root.go
46 lines (36 loc) · 941 Bytes
/
root.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
package cmd
import (
"fmt"
"os"
"runtime"
"github.com/fatih/color"
"github.com/keygen-sh/keygen-cli/internal/keygenext"
"github.com/spf13/cobra"
)
var (
rootCmd = &cobra.Command{
Use: "keygen",
Short: "CLI to interact with keygen.sh",
Long: `CLI to interact with keygen.sh
Version:
keygen/` + Version + " " + runtime.GOOS + "-" + runtime.GOARCH + " " + runtime.Version(),
Version: Version,
SilenceErrors: true,
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
}
)
func init() {
keygenext.UserAgent = "cli/" + Version
rootCmd.PersistentFlags().BoolVar(&color.NoColor, "no-color", false, "disable colors in command output [$NO_COLOR=1]")
rootCmd.InitDefaultVersionFlag()
rootCmd.InitDefaultHelpFlag()
rootCmd.SetHelpCommand(helpCmd)
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Fprintln(os.Stderr, red("error:")+" "+err.Error())
os.Exit(1)
}
}