root.go 2.3 KB

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