package cmd import ( "fmt" "os" "git.abrell.se/victor/mydev/internal/config" "github.com/spf13/cobra" ) var configCmd = &cobra.Command{ Use: "config", Short: "Manage the config file", } var configPathCmd = &cobra.Command{ Use: "path", Short: "Print the config file path", Run: func(cmd *cobra.Command, args []string) { p, err := config.Path() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } fmt.Println(p) }, } var configInitCmd = &cobra.Command{ Use: "init", Short: "Write a starter config file", Run: func(cmd *cobra.Command, args []string) { p, err := config.Init() if err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) } fmt.Printf("wrote %s — edit repos_roots to your paths\n", p) }, } func init() { configCmd.AddCommand(configPathCmd, configInitCmd) rootCmd.AddCommand(configCmd) }