root.go 1.9 KB

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