root.go 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. package cmd
  2. import (
  3. "os"
  4. "github.com/gravitl/netmaker/cli/cmd/acl"
  5. "github.com/gravitl/netmaker/cli/cmd/commons"
  6. "github.com/gravitl/netmaker/cli/cmd/context"
  7. "github.com/gravitl/netmaker/cli/cmd/dns"
  8. "github.com/gravitl/netmaker/cli/cmd/enrollment_key"
  9. "github.com/gravitl/netmaker/cli/cmd/ext_client"
  10. "github.com/gravitl/netmaker/cli/cmd/host"
  11. "github.com/gravitl/netmaker/cli/cmd/keys"
  12. "github.com/gravitl/netmaker/cli/cmd/metrics"
  13. "github.com/gravitl/netmaker/cli/cmd/network"
  14. "github.com/gravitl/netmaker/cli/cmd/network_user"
  15. "github.com/gravitl/netmaker/cli/cmd/node"
  16. "github.com/gravitl/netmaker/cli/cmd/server"
  17. "github.com/gravitl/netmaker/cli/cmd/user"
  18. "github.com/gravitl/netmaker/cli/cmd/usergroup"
  19. "github.com/spf13/cobra"
  20. )
  21. // rootCmd represents the base command when called without any subcommands
  22. var rootCmd = &cobra.Command{
  23. Use: "nmctl",
  24. Short: "CLI for interacting with Netmaker Server",
  25. Long: `CLI for interacting with Netmaker Server`,
  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. rootCmd.PersistentFlags().StringVarP(&commons.OutputFormat, "output", "o", "", "List output in specific format (Enum:- json)")
  41. // Bind subcommands here
  42. rootCmd.AddCommand(network.GetRoot())
  43. rootCmd.AddCommand(context.GetRoot())
  44. rootCmd.AddCommand(keys.GetRoot())
  45. rootCmd.AddCommand(acl.GetRoot())
  46. rootCmd.AddCommand(node.GetRoot())
  47. rootCmd.AddCommand(dns.GetRoot())
  48. rootCmd.AddCommand(server.GetRoot())
  49. rootCmd.AddCommand(ext_client.GetRoot())
  50. rootCmd.AddCommand(user.GetRoot())
  51. rootCmd.AddCommand(usergroup.GetRoot())
  52. rootCmd.AddCommand(metrics.GetRoot())
  53. rootCmd.AddCommand(network_user.GetRoot())
  54. rootCmd.AddCommand(host.GetRoot())
  55. rootCmd.AddCommand(enrollment_key.GetRoot())
  56. }