|
@@ -5,23 +5,31 @@ import (
|
|
"os"
|
|
"os"
|
|
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/cobra"
|
|
|
|
+ "github.com/spf13/viper"
|
|
)
|
|
)
|
|
|
|
|
|
var cmd = &cobra.Command{
|
|
var cmd = &cobra.Command{
|
|
Use: "kurzd",
|
|
Use: "kurzd",
|
|
Short: "kurzd is the Kurz daemon and back-office command",
|
|
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",
|
|
|
|
- Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
- panic("Not yet implemented")
|
|
|
|
- },
|
|
|
|
|
|
+ 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() {
|
|
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() {
|
|
func init() {
|
|
cobra.OnInitialize(initConfig)
|
|
cobra.OnInitialize(initConfig)
|
|
|
|
+ verbose = *cmd.PersistentFlags().BoolP("verbose", "v", false, "Add -v for verbose operation")
|
|
}
|
|
}
|
|
|
|
|
|
func Execute() {
|
|
func Execute() {
|