add SetYes to profile set command
This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user