/* Copyright © 2025 NAME HERE */ package cmd import ( "bufio" "fmt" "os" "github.com/spf13/cobra" "github.com/spf13/viper" ) var ( name string // cmd string ) // saveCmd represents the save command var saveCmd = &cobra.Command{ Use: "save", Short: "A brief description of your command", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, Run: func(cmd *cobra.Command, args []string) { // fmt.Println("save called") // viper.Set("testcmd", "im doin stuff and testing a command idea ' idk") // viper.WriteConfig() // fmt.Println(viper.Get("testcmd")) // fmt.Println(name) // fmt.Println(cmd) fmt.Printf("Command: ") sc := bufio.NewScanner(os.Stdin) if sc.Scan() { txt := sc.Text() if txt != "" { viper.Set(name, txt) viper.WriteConfig() fmt.Println("\nSaved!") return } } }, } func init() { rootCmd.AddCommand(saveCmd) // Here you will define your flags and configuration settings. // Cobra supports Persistent Flags which will work for this command // and all subcommands, e.g.: // saveCmd.PersistentFlags().String("foo", "", "A help for foo") // Cobra supports local flags which will only run when this command // is called directly, e.g.: // saveCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle") saveCmd.Flags().StringVar(&name, "name", "", "") saveCmd.MarkFlagRequired("name") // saveCmd.Flags().StringVar(&cmd, "command", "", "") // saveCmd.MarkFlagRequired("command") }