apps-durpcli/cmd/cfg/newconfig.go

32 lines
505 B
Go
Raw Normal View History

2023-05-27 11:43:24 -05:00
package cfg
import (
2024-06-23 16:27:55 -05:00
"os"
"os/user"
2023-05-27 11:43:24 -05:00
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var newcfgcmd = &cobra.Command{
Use: "newconfig",
Short: "Generates a config file using current config",
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
2024-06-23 16:27:55 -05:00
usr, err := user.Current()
2023-05-27 11:43:24 -05:00
if err != nil {
2024-06-23 16:27:55 -05:00
os.Exit(1)
2023-05-27 11:43:24 -05:00
}
2024-06-23 16:27:55 -05:00
viper.SetConfigType("yaml")
viper.SetConfigName(".durpcli")
viper.AddConfigPath(usr.HomeDir)
viper.WriteConfig()
2023-05-27 11:43:24 -05:00
},
}
func init() {
Cfgcmd.AddCommand(newcfgcmd)
}