Refactor routes cmd

This commit is contained in:
ohdearaugustin 2021-07-25 15:08:40 +02:00
parent e56755fd67
commit d87a4c87cc

View file

@ -8,12 +8,19 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
var RoutesCmd = &cobra.Command{ func init() {
rootCmd.AddCommand(routesCmd)
routesCmd.PersistentFlags().StringP("namespace", "n", "", "Namespace")
routesCmd.AddCommand(listRoutesCmd)
routesCmd.AddCommand(enableRouteCmd)
}
var routesCmd = &cobra.Command{
Use: "routes", Use: "routes",
Short: "Manage the routes of Headscale", Short: "Manage the routes of Headscale",
} }
var ListRoutesCmd = &cobra.Command{ var listRoutesCmd = &cobra.Command{
Use: "list NODE", Use: "list NODE",
Short: "List the routes exposed by this node", Short: "List the routes exposed by this node",
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {
@ -49,7 +56,7 @@ var ListRoutesCmd = &cobra.Command{
}, },
} }
var EnableRouteCmd = &cobra.Command{ var enableRouteCmd = &cobra.Command{
Use: "enable node-name route", Use: "enable node-name route",
Short: "Allows exposing a route declared by this node to the rest of the nodes", Short: "Allows exposing a route declared by this node to the rest of the nodes",
Args: func(cmd *cobra.Command, args []string) error { Args: func(cmd *cobra.Command, args []string) error {