command_line.go 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. package utils
  2. import (
  3. "github.com/codegangsta/cli"
  4. )
  5. type CommandLine interface {
  6. ShowHelp()
  7. ShowVersion()
  8. Application() *cli.App
  9. Args() cli.Args
  10. Bool(name string) bool
  11. Int(name string) int
  12. String(name string) string
  13. StringSlice(name string) []string
  14. GlobalString(name string) string
  15. FlagNames() (names []string)
  16. Generic(name string) interface{}
  17. PluginDirectory() string
  18. RepoDirectory() string
  19. PluginURL() string
  20. }
  21. type ContextCommandLine struct {
  22. *cli.Context
  23. }
  24. func (c *ContextCommandLine) ShowHelp() {
  25. cli.ShowCommandHelp(c.Context, c.Command.Name)
  26. }
  27. func (c *ContextCommandLine) ShowVersion() {
  28. cli.ShowVersion(c.Context)
  29. }
  30. func (c *ContextCommandLine) Application() *cli.App {
  31. return c.App
  32. }
  33. func (c *ContextCommandLine) PluginDirectory() string {
  34. return c.GlobalString("pluginsDir")
  35. }
  36. func (c *ContextCommandLine) RepoDirectory() string {
  37. return c.GlobalString("repo")
  38. }
  39. func (c *ContextCommandLine) PluginURL() string {
  40. return c.GlobalString("pluginUrl")
  41. }