From 2862c2034b4236ef11d1774d6fbe81b92d5bd187 Mon Sep 17 00:00:00 2001 From: ohdearaugustin Date: Sun, 25 Jul 2021 15:04:06 +0200 Subject: [PATCH] Refactor nodes cmd --- cmd/headscale/cli/nodes.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cmd/headscale/cli/nodes.go b/cmd/headscale/cli/nodes.go index 92dd6690..7a773cef 100644 --- a/cmd/headscale/cli/nodes.go +++ b/cmd/headscale/cli/nodes.go @@ -11,12 +11,20 @@ import ( "github.com/spf13/cobra" ) -var NodeCmd = &cobra.Command{ +func init () { + nodeCmd.PersistentFlags().StringP("namespace", "n", "", "Namespace") + nodeCmd.MarkPersistentFlagRequired("namespace") + nodeCmd.AddCommand(listNodesCmd) + nodeCmd.AddCommand(registerNodeCmd) + nodeCmd.AddCommand(deleteNodeCmd) +} + +var nodeCmd = &cobra.Command{ Use: "nodes", Short: "Manage the nodes of Headscale", } -var RegisterCmd = &cobra.Command{ +var registerNodeCmd = &cobra.Command{ Use: "register machineID", Short: "Registers a machine to your network", Args: func(cmd *cobra.Command, args []string) error { @@ -49,7 +57,7 @@ var RegisterCmd = &cobra.Command{ }, } -var ListNodesCmd = &cobra.Command{ +var listNodesCmd = &cobra.Command{ Use: "list", Short: "List the nodes in a given namespace", Run: func(cmd *cobra.Command, args []string) { @@ -89,7 +97,7 @@ var ListNodesCmd = &cobra.Command{ }, } -var DeleteCmd = &cobra.Command{ +var deleteNodeCmd = &cobra.Command{ Use: "delete ID", Short: "Delete a node", Args: func(cmd *cobra.Command, args []string) error {