cmd.go 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package env
  2. import "github.com/spf13/cobra"
  3. var (
  4. sliceVarWriteValue []string
  5. boolVarForce bool
  6. boolVarVerbose bool
  7. boolVarInstall bool
  8. // Cmd describes an env command.
  9. Cmd = &cobra.Command{
  10. Use: "env",
  11. Short: "Check or edit goctl environment",
  12. RunE: write,
  13. }
  14. installCmd = &cobra.Command{
  15. Use: "install",
  16. Short: "Goctl env installation",
  17. RunE: install,
  18. }
  19. checkCmd = &cobra.Command{
  20. Use: "check",
  21. Short: "Detect goctl env and dependency tools",
  22. RunE: check,
  23. }
  24. )
  25. func init() {
  26. // The root command flags
  27. Cmd.Flags().StringSliceVarP(&sliceVarWriteValue,
  28. "write", "w", nil, "Edit goctl environment")
  29. Cmd.PersistentFlags().BoolVarP(&boolVarForce,
  30. "force", "f", false,
  31. "Silent installation of non-existent dependencies")
  32. Cmd.PersistentFlags().BoolVarP(&boolVarVerbose,
  33. "verbose", "v", false, "Enable log output")
  34. // The sub-command flags
  35. checkCmd.Flags().BoolVarP(&boolVarInstall, "install", "i",
  36. false, "Install dependencies if not found")
  37. // Add sub-command
  38. Cmd.AddCommand(installCmd)
  39. Cmd.AddCommand(checkCmd)
  40. }