Merge branch 'main' of https://github.com/juanfont/headscale into main
This commit is contained in:
commit
2ddca366f2
3 changed files with 20 additions and 1 deletions
|
@ -129,6 +129,7 @@ var deleteNodeCmd = &cobra.Command{
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
output, _ := cmd.Flags().GetString("output")
|
||||||
h, err := getHeadscaleApp()
|
h, err := getHeadscaleApp()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error initializing: %s", err)
|
log.Fatalf("Error initializing: %s", err)
|
||||||
|
@ -153,11 +154,19 @@ var deleteNodeCmd = &cobra.Command{
|
||||||
|
|
||||||
if confirm {
|
if confirm {
|
||||||
err = h.DeleteMachine(m)
|
err = h.DeleteMachine(m)
|
||||||
|
if strings.HasPrefix(output, "json") {
|
||||||
|
JsonOutput(map[string]string{"Result": "Node deleted"}, err, output)
|
||||||
|
return
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("Error deleting node: %s", err)
|
log.Fatalf("Error deleting node: %s", err)
|
||||||
}
|
}
|
||||||
fmt.Printf("Node deleted\n")
|
fmt.Printf("Node deleted\n")
|
||||||
} else {
|
} else {
|
||||||
|
if strings.HasPrefix(output, "json") {
|
||||||
|
JsonOutput(map[string]string{"Result": "Node not deleted"}, err, output)
|
||||||
|
return
|
||||||
|
}
|
||||||
fmt.Printf("Node not deleted\n")
|
fmt.Printf("Node not deleted\n")
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -262,3 +262,12 @@ func JsonOutput(result interface{}, errResult error, outputFormat string) {
|
||||||
}
|
}
|
||||||
fmt.Println(string(j))
|
fmt.Println(string(j))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func HasJsonOutputFlag() bool {
|
||||||
|
for _, arg := range os.Args {
|
||||||
|
if arg == "json" || arg == "json-line" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
|
@ -62,7 +62,8 @@ func main() {
|
||||||
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
zerolog.SetGlobalLevel(zerolog.DebugLevel)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !viper.GetBool("disable_check_updates") {
|
jsonOutput := cli.HasJsonOutputFlag()
|
||||||
|
if !viper.GetBool("disable_check_updates") && !jsonOutput {
|
||||||
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && cli.Version != "dev" {
|
if (runtime.GOOS == "linux" || runtime.GOOS == "darwin") && cli.Version != "dev" {
|
||||||
githubTag := &latest.GithubTag{
|
githubTag := &latest.GithubTag{
|
||||||
Owner: "juanfont",
|
Owner: "juanfont",
|
||||||
|
|
Loading…
Reference in a new issue