root.go 1.6 KB

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