command_line.go 891 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package commands
  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. }
  20. type contextCommandLine struct {
  21. *cli.Context
  22. }
  23. func (c *contextCommandLine) ShowHelp() {
  24. cli.ShowCommandHelp(c.Context, c.Command.Name)
  25. }
  26. func (c *contextCommandLine) ShowVersion() {
  27. cli.ShowVersion(c.Context)
  28. }
  29. func (c *contextCommandLine) Application() *cli.App {
  30. return c.App
  31. }
  32. func (c *contextCommandLine) PluginDirectory() string {
  33. return c.GlobalString("pluginsDir")
  34. }
  35. func (c *contextCommandLine) RepoDirectory() string {
  36. return c.GlobalString("repo")
  37. }