add SetYes to profile delete command

This commit is contained in:
Cooper, Trevor
2021-04-15 08:05:06 -07:00
parent cbb0e46bac
commit 505ee9f32a
2 changed files with 19 additions and 11 deletions

View File

@@ -48,19 +48,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
}
if count > 0 {
q := fmt.Sprintf("Are you sure you want to delete %d profile(s) (%d groups, %d nodes)", count, numGroups, numNodes)
prompt := promptui.Prompt{
Label: q,
IsConfirm: true,
}
result, _ := prompt.Run()
if result == "y" || result == "yes" {
if SetYes == true {
nodeDB.Persist()
}
} else {
q := fmt.Sprintf("Are you sure you want to delete %d profile(s) (%d groups, %d nodes)", count, numGroups, numNodes)
prompt := promptui.Prompt{
Label: q,
IsConfirm: true,
}
result, _ := prompt.Run()
if result == "y" || result == "yes" {
nodeDB.Persist()
}
}
} else {
wwlog.Printf(wwlog.INFO, "No groups found\n")
}

View File

@@ -10,8 +10,13 @@ var (
RunE: CobraRunE,
Args: cobra.MinimumNArgs(1),
}
SetYes bool
)
func init() {
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
}
// GetRootCommand returns the root cobra.Command for the application.
func GetCommand() *cobra.Command {
return baseCmd