rootCmd.go 742 B

123456789101112131415161718192021222324252627282930313233
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. "github.com/spf13/cobra"
  6. "github.com/spf13/viper"
  7. )
  8. var cmd = &cobra.Command{
  9. Use: "kurzd",
  10. Short: "kurzd is the Kurz daemon and back-office command",
  11. Long: `kurzd is the actual engine for Kurz. Use it as the server for your Kurz clients.
  12. Configure it by copying dist.config.yml to ~/.kurz/config.yml and editing the copy.`,
  13. }
  14. var verbose bool
  15. func initConfig() {
  16. viper.SetConfigName("config")
  17. viper.AddConfigPath(".")
  18. viper.AddConfigPath("$HOME/.kurz")
  19. err := viper.ReadInConfig()
  20. if err != nil {
  21. fmt.Fprintln(os.Stderr, err)
  22. os.Exit(2)
  23. }
  24. }
  25. func init() {
  26. cobra.OnInitialize(initConfig)
  27. verbose = *cmd.PersistentFlags().BoolP("verbose", "v", false, "Add -v for verbose operation")
  28. }