root.go 1.8 KB

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