-
Notifications
You must be signed in to change notification settings - Fork 27
/
root.go
47 lines (41 loc) · 885 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
47
/*
Copyright © 2022 AssemblyAI support@assemblyai.com
*/
package cmd
import (
"fmt"
"os"
"github.com/joho/godotenv"
"github.com/spf13/cobra"
)
var VERSION string
var rootCmd = &cobra.Command{
Use: "assemblyai",
Short: "AssemblyAI CLI",
Long: `Please authenticate to use the CLI.
assemblyai config [token]`,
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
Run: func(cmd *cobra.Command, args []string) {
versionFlag, _ := cmd.Flags().GetBool("version")
if versionFlag {
if VERSION == "" {
godotenv.Load()
VERSION = os.Getenv("VERSION")
}
fmt.Printf("AssemblyAI CLI %s\n", VERSION)
} else {
cmd.Help()
}
},
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
os.Exit(1)
}
}
func init() {
rootCmd.PersistentFlags().BoolP("version", "v", false, "Check current installed version.")
}