root.go 1.4 KB

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