root.go 2.2 KB

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