root.go 1.4 KB

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