mirror of
				https://github.com/juanfont/headscale.git
				synced 2025-10-28 10:51:44 +01:00 
			
		
		
		
	Merge pull request #171 from juanfont/force-flag
Added --force flag on node delete
This commit is contained in:
		
						commit
						a9a1a8fb3c
					
				@ -144,15 +144,18 @@ var deleteNodeCmd = &cobra.Command{
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		confirm := false
 | 
							confirm := false
 | 
				
			||||||
		prompt := &survey.Confirm{
 | 
							force, _ := cmd.Flags().GetBool("force")
 | 
				
			||||||
			Message: fmt.Sprintf("Do you want to remove the node %s?", m.Name),
 | 
							if !force {
 | 
				
			||||||
		}
 | 
								prompt := &survey.Confirm{
 | 
				
			||||||
		err = survey.AskOne(prompt, &confirm)
 | 
									Message: fmt.Sprintf("Do you want to remove the node %s?", m.Name),
 | 
				
			||||||
		if err != nil {
 | 
								}
 | 
				
			||||||
			return
 | 
								err = survey.AskOne(prompt, &confirm)
 | 
				
			||||||
 | 
								if err != nil {
 | 
				
			||||||
 | 
									return
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if confirm {
 | 
							if confirm || force {
 | 
				
			||||||
			err = h.DeleteMachine(m)
 | 
								err = h.DeleteMachine(m)
 | 
				
			||||||
			if strings.HasPrefix(output, "json") {
 | 
								if strings.HasPrefix(output, "json") {
 | 
				
			||||||
				JsonOutput(map[string]string{"Result": "Node deleted"}, err, output)
 | 
									JsonOutput(map[string]string{"Result": "Node deleted"}, err, output)
 | 
				
			||||||
 | 
				
			|||||||
@ -9,6 +9,7 @@ import (
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
	rootCmd.PersistentFlags().StringP("output", "o", "", "Output format. Empty for human-readable, 'json' or 'json-line'")
 | 
						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{
 | 
					var rootCmd = &cobra.Command{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user