root.go 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. package cmd
  2. import (
  3. "os"
  4. "github.com/gravitl/netmaker/cli/cmd/acl"
  5. "github.com/gravitl/netmaker/cli/cmd/context"
  6. "github.com/gravitl/netmaker/cli/cmd/dns"
  7. "github.com/gravitl/netmaker/cli/cmd/ext_client"
  8. "github.com/gravitl/netmaker/cli/cmd/keys"
  9. "github.com/gravitl/netmaker/cli/cmd/metrics"
  10. "github.com/gravitl/netmaker/cli/cmd/network"
  11. "github.com/gravitl/netmaker/cli/cmd/node"
  12. "github.com/gravitl/netmaker/cli/cmd/server"
  13. "github.com/gravitl/netmaker/cli/cmd/user"
  14. "github.com/gravitl/netmaker/cli/cmd/usergroup"
  15. "github.com/spf13/cobra"
  16. )
  17. // rootCmd represents the base command when called without any subcommands
  18. var rootCmd = &cobra.Command{
  19. Use: "netmaker",
  20. Short: "CLI for interacting with Netmaker Server",
  21. Long: `CLI for interacting with Netmaker Server`,
  22. // Uncomment the following line if your bare application
  23. // has an action associated with it:
  24. // Run: func(cmd *cobra.Command, args []string) { },
  25. }
  26. func GetRoot() *cobra.Command {
  27. return rootCmd
  28. }
  29. // Execute adds all child commands to the root command and sets flags appropriately.
  30. // This is called by main.main(). It only needs to happen once to the rootCmd.
  31. func Execute() {
  32. err := rootCmd.Execute()
  33. if err != nil {
  34. os.Exit(1)
  35. }
  36. }
  37. func init() {
  38. // Here you will define your flags and configuration settings.
  39. // Cobra supports persistent flags, which, if defined here,
  40. // will be global for your application.
  41. // rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.tctl.yaml)")
  42. // Cobra also supports local flags, which will only run
  43. // when this action is called directly.
  44. rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
  45. // IMP: Bind subcommands here
  46. rootCmd.AddCommand(network.GetRoot())
  47. rootCmd.AddCommand(context.GetRoot())
  48. rootCmd.AddCommand(keys.GetRoot())
  49. rootCmd.AddCommand(acl.GetRoot())
  50. rootCmd.AddCommand(node.GetRoot())
  51. rootCmd.AddCommand(dns.GetRoot())
  52. rootCmd.AddCommand(server.GetRoot())
  53. rootCmd.AddCommand(ext_client.GetRoot())
  54. rootCmd.AddCommand(user.GetRoot())
  55. rootCmd.AddCommand(usergroup.GetRoot())
  56. rootCmd.AddCommand(metrics.GetRoot())
  57. }