diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index c01bce9..1246192 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -144,15 +144,18 @@ var deleteNodeCmd = &cobra.Command{ } confirm := false - prompt := &survey.Confirm{ - Message: fmt.Sprintf("Do you want to remove the node %s?", m.Name), - } - err = survey.AskOne(prompt, &confirm) - if err != nil { - return + force, _ := cmd.Flags().GetBool("force") + if !force { + prompt := &survey.Confirm{ + Message: fmt.Sprintf("Do you want to remove the node %s?", m.Name), + } + err = survey.AskOne(prompt, &confirm) + if err != nil { + return + } } - if confirm { + if confirm || force { err = h.DeleteMachine(m) if strings.HasPrefix(output, "json") { JsonOutput(map[string]string{"Result": "Node deleted"}, err, output) diff --git a/cmd/headscale/cli/root.go b/cmd/headscale/cli/root.go index 21857d8..794cd0d 100644 --- a/cmd/headscale/cli/root.go +++ b/cmd/headscale/cli/root.go @@ -9,6 +9,7 @@ import ( func init() { rootCmd.PersistentFlags().StringP("output", "o", "", "Output format. Empty for human-readable, 'json' or 'json-line'") + rootCmd.PersistentFlags().Bool("force", false, "Disable prompts and forces the execution") } var rootCmd = &cobra.Command{