29
29
30
30
// rootCmd represents the base command when called without any subcommands
31
31
rootCmd = & cobra.Command {
32
- Use : "ots" ,
33
- Short : "Easily create and share end-to-end encrypted secrets with others" ,
34
- // Long: `A longer description that spans multiple lines and likely contains
35
- // examples and usage of using your application. For example:
36
-
37
- // Cobra is a CLI library for Go that empowers applications.
38
- // This application is a tool to generate the needed files
39
- // to quickly create a Cobra application.`,
40
- // Uncomment the following line if your bare application
41
- // has an action associated with it:
42
- // Run: func(cmd *cobra.Command, args []string) { },
32
+ Use : "ots" ,
33
+ Short : "Easily create and share end-to-end encrypted secrets with others" ,
43
34
Version : build .Version ,
44
35
}
45
36
)
@@ -53,15 +44,7 @@ func Execute() {
53
44
func init () {
54
45
cobra .OnInitialize (initConfig )
55
46
56
- // Here you will define your flags and configuration settings.
57
- // Cobra supports persistent flags, which, if defined here,
58
- // will be global for your application.
59
-
60
47
rootCmd .PersistentFlags ().StringVar (& cfgFile , "config" , "" , "config file (default is $HOME/.ots.yaml)" )
61
-
62
- // Cobra also supports local flags, which will only run
63
- // when this action is called directly.
64
- // rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
65
48
}
66
49
67
50
// initConfig reads in config file and ENV variables if set.
@@ -78,9 +61,11 @@ func initConfig() {
78
61
viper .AddConfigPath (home )
79
62
viper .SetConfigType ("yaml" )
80
63
viper .SetConfigName (".ots" )
64
+ viper .SetDefault ("base_url" , build .BaseUrl )
81
65
}
82
66
83
- viper .AutomaticEnv () // read in environment variables that match
67
+ // Read in environment variables that match.
68
+ viper .AutomaticEnv ()
84
69
85
70
// If a config file is found, read it in.
86
71
if err := viper .ReadInConfig (); err == nil {
0 commit comments