add SetYes to node delete command
This commit is contained in:
@@ -31,19 +31,22 @@ func CobraRunE(cmd *cobra.Command, args []string) error {
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
q := fmt.Sprintf("Are you sure you want to delete %d nodes(s)", count)
|
||||
|
||||
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 nodes(s)", count)
|
||||
|
||||
prompt := promptui.Prompt{
|
||||
Label: q,
|
||||
IsConfirm: true,
|
||||
}
|
||||
|
||||
result, _ := prompt.Run()
|
||||
|
||||
if result == "y" || result == "yes" {
|
||||
nodeDB.Persist()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
fmt.Printf("No nodes found\n")
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ var (
|
||||
RunE: CobraRunE,
|
||||
Aliases: []string{"rm", "del"},
|
||||
}
|
||||
SetYes bool
|
||||
SetForce string
|
||||
SetGroup string
|
||||
SetController string
|
||||
@@ -20,6 +21,7 @@ func init() {
|
||||
baseCmd.PersistentFlags().StringVarP(&SetForce, "force", "f", "", "Force node delete")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetGroup, "group", "g", "default", "Set group to delete nodes from")
|
||||
baseCmd.PersistentFlags().StringVarP(&SetController, "controller", "c", "default", "Controller to add nodes to")
|
||||
baseCmd.PersistentFlags().BoolVarP(&SetYes, "yes", "y", false, "Set 'yes' to all questions asked")
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user