add SetYes to profile set command

This commit is contained in:
Cooper, Trevor
2021-04-15 02:19:38 -07:00
parent 3c6837f922
commit cbb0e46bac
2 changed files with 17 additions and 12 deletions

View File

@@ -257,20 +257,23 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if len(profiles) > 0 {
q := fmt.Sprintf("Are you sure you want to modify %d profile(s)", len(profiles))
prompt := promptui.Prompt{
Label: q,
IsConfirm: true,
}
result, _ := prompt.Run()
if result == "y" || result == "yes" {
if SetYes == true {
nodeDB.Persist()
warewulfd.DaemonReload()
}
} else {
q := fmt.Sprintf("Are you sure you want to modify %d profile(s)", len(profiles))
prompt := promptui.Prompt{
Label: q,
IsConfirm: true,
}
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
warewulfd.DaemonReload()
}
}
} else {
fmt.Printf("No profiles found\n")
}

View File

@@ -11,6 +11,7 @@ var (
RunE: CobraRunE,
}
SetAll bool
SetYes bool
SetForce bool
SetComment string
SetContainer string
@@ -64,6 +65,7 @@ func init() {
baseCmd.PersistentFlags().BoolVarP(&SetAll, "all", "a", false, "Set all profiles")
baseCmd.PersistentFlags().BoolVarP(&SetForce, "force", "f", false, "Force configuration (even on error)")
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
}
// GetRootCommand returns the root cobra.Command for the application.