2019-05-27 16:47:21 +08:00
|
|
|
package utils
|
2016-02-15 21:09:34 +08:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/codegangsta/cli"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type CommandLine interface {
|
|
|
|
|
ShowHelp()
|
|
|
|
|
ShowVersion()
|
|
|
|
|
Application() *cli.App
|
|
|
|
|
Args() cli.Args
|
|
|
|
|
Bool(name string) bool
|
|
|
|
|
Int(name string) int
|
|
|
|
|
String(name string) string
|
|
|
|
|
StringSlice(name string) []string
|
|
|
|
|
GlobalString(name string) string
|
|
|
|
|
FlagNames() (names []string)
|
|
|
|
|
Generic(name string) interface{}
|
2016-06-25 02:14:58 +08:00
|
|
|
|
|
|
|
|
PluginDirectory() string
|
|
|
|
|
RepoDirectory() string
|
2017-09-16 02:34:08 +08:00
|
|
|
PluginURL() string
|
2016-02-15 21:09:34 +08:00
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
type ContextCommandLine struct {
|
2016-02-15 21:09:34 +08:00
|
|
|
*cli.Context
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) ShowHelp() {
|
2016-02-15 21:09:34 +08:00
|
|
|
cli.ShowCommandHelp(c.Context, c.Command.Name)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) ShowVersion() {
|
2016-02-15 21:09:34 +08:00
|
|
|
cli.ShowVersion(c.Context)
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) Application() *cli.App {
|
2016-02-15 21:09:34 +08:00
|
|
|
return c.App
|
|
|
|
|
}
|
2016-06-25 02:14:58 +08:00
|
|
|
|
2019-06-25 03:20:21 +08:00
|
|
|
func (c *ContextCommandLine) HomePath() string { return c.GlobalString("homepath") }
|
|
|
|
|
|
|
|
|
|
func (c *ContextCommandLine) ConfigFile() string { return c.GlobalString("config") }
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) PluginDirectory() string {
|
2016-06-25 02:14:58 +08:00
|
|
|
return c.GlobalString("pluginsDir")
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) RepoDirectory() string {
|
2016-06-25 02:14:58 +08:00
|
|
|
return c.GlobalString("repo")
|
|
|
|
|
}
|
2017-09-16 02:34:08 +08:00
|
|
|
|
2019-05-27 16:47:21 +08:00
|
|
|
func (c *ContextCommandLine) PluginURL() string {
|
2017-09-16 02:34:08 +08:00
|
|
|
return c.GlobalString("pluginUrl")
|
|
|
|
|
}
|
2019-06-25 03:20:21 +08:00
|
|
|
|
|
|
|
|
func (c *ContextCommandLine) OptionsString() string {
|
|
|
|
|
return c.GlobalString("configOverrides")
|
|
|
|
|
}
|