package main import ( "fmt" "os" "github.com/spf13/cobra" "github.com/spf13/viper" ) var cmd = &cobra.Command{ Use: "kurzd", Short: "kurzd is the Kurz daemon and back-office command", Long: `kurzd is the actual engine for Kurz. Use it as the server for your Kurz clients. Configure it by copying dist.config.yml to ~/.kurz/config.yml and editing the copy.`, } var verbose bool func initConfig() { viper.SetConfigName("config") viper.AddConfigPath(".") viper.AddConfigPath("$HOME/.kurz") err := viper.ReadInConfig() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(2) } } func init() { cobra.OnInitialize(initConfig) verbose = *cmd.PersistentFlags().BoolP("verbose", "v", false, "Add -v for verbose operation") }