-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
65 lines (51 loc) · 1.51 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"fmt"
"os"
"strings"
"github.com/darrenparkinson/wtr/cmd"
"github.com/morikuni/aec"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// version is a linker flag set by goreleaser
var version = "0.0.0"
func main() {
viper.AddConfigPath(".")
viper.SetConfigName(".wtr-cli")
viper.SetConfigType("json")
_ = viper.SafeWriteConfig()
_ = viper.ReadInConfig()
viper.SetEnvPrefix("webex")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
cmdRetrieve := cmd.RetrieveCmd()
cmdRefresh := cmd.RefreshCmd()
var rootCmd = &cobra.Command{
Use: "wtr",
Short: "Webex Token Retriever/Refresher",
Version: version,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
},
}
rootCmd.SilenceUsage = true
rootCmd.SilenceErrors = true
rootCmd.CompletionOptions.DisableDefaultCmd = true
rootCmd.AddCommand(cmdRetrieve)
rootCmd.AddCommand(cmdRefresh)
rootCmd.PersistentFlags().BoolP("debug", "d", false, "verbose debug output")
rootCmd.SetHelpCommand(&cobra.Command{Hidden: true})
wtrLogo := aec.GreenF.Apply(wtrFigletStr)
rootCmd.SetVersionTemplate(fmt.Sprintf("%s\nv{{.Version}}\nhttps://github.com/darrenparkinson/wtr\n", wtrLogo))
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
const wtrFigletStr = ` _
__ _| |_ _ __ 2
\ \ /\ / / __| '__|
\ V V /| |_| |
\_/\_/ \__|_|
`