package remote import ( "log" "git.cryptic.systems/fh-trier/go-flucky/pkg/config" "github.com/spf13/cobra" ) var enabled bool var addRemoteCmd = &cobra.Command{ Use: "add", Short: "Add Remove Server", Args: cobra.ExactArgs(2), Run: func(cmd *cobra.Command, args []string) { // read configuration fc, err := config.Read(cfg) if err != nil { log.Fatalln(err) } // create new remote struct remote := config.Remote{ Name: args[0], Address: args[1], Enabled: enabled, } // // add remote entry to list err = fc.AddRemote(&remote) if err != nil { log.Fatalln(err) } // save new configuration err = config.Write(fc, cfg) if err != nil { log.Fatalln(err) } }, } func init() { remoteCmd.AddCommand(addRemoteCmd) addRemoteCmd.Flags().BoolVarP(&enabled, "enable", "e", true, "Enable") }