本文整理匯總了Golang中cf/commands.Runner類的典型用法代碼示例。如果您正苦於以下問題:Golang Runner類的具體用法?Golang Runner怎麽用?Golang Runner使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Runner類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: NewApp
func NewApp(cmdRunner commands.Runner) (app *cli.App, err error) {
helpCommand := cli.Command{
Name: "help",
ShortName: "h",
Description: "Show help",
Usage: fmt.Sprintf("%s help [COMMAND]", cf.Name()),
Action: func(c *cli.Context) {
args := c.Args()
if len(args) > 0 {
cli.ShowCommandHelp(c, args[0])
} else {
showAppHelp(c.App)
}
},
}
app = cli.NewApp()
app.Usage = cf.Usage
app.Version = cf.Version
app.Action = helpCommand.Action
app.Commands = []cli.Command{
helpCommand,
{
Name: "api",
Description: "Set or view target api url",
Usage: fmt.Sprintf("%s api [URL]", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("api", c)
},
},
{
Name: "app",
Description: "Display health and status for app",
Usage: fmt.Sprintf("%s app APP", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("app", c)
},
},
{
Name: "apps",
ShortName: "a",
Description: "List all apps in the target space",
Usage: fmt.Sprintf("%s apps", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("apps", c)
},
},
{
Name: "auth",
Description: "Authenticate user non-interactively",
Usage: fmt.Sprintf("%s auth USERNAME PASSWORD\n\n", cf.Name()) +
terminal.WarningColor("WARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history\n\n") +
"EXAMPLE:\n" +
fmt.Sprintf(" %s auth [email protected] \"my password\" (use quotes for passwords with a space)\n", cf.Name()) +
fmt.Sprintf(" %s auth [email protected] \"\\\"password\\\"\" (escape quotes if used in password)", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("auth", c)
},
},
{
Name: "bind-service",
ShortName: "bs",
Description: "Bind a service instance to an app",
Usage: fmt.Sprintf("%s bind-service APP SERVICE_INSTANCE", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("bind-service", c)
},
},
{
Name: "buildpacks",
Description: "List all buildpacks",
Usage: fmt.Sprintf("%s buildpacks", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("buildpacks", c)
},
},
{
Name: "create-buildpack",
Description: "Create a buildpack",
Usage: fmt.Sprintf("%s create-buildpack BUILDPACK PATH POSITION [--enable|--disable]", cf.Name()),
Flags: []cli.Flag{
cli.BoolFlag{Name: "enable", Usage: "Enable the buildpack"},
cli.BoolFlag{Name: "disable", Usage: "Disable the buildpack"},
},
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("create-buildpack", c)
},
},
{
Name: "create-domain",
Description: "Create a domain in an org for later use",
Usage: fmt.Sprintf("%s create-domain ORG DOMAIN", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("create-domain", c)
},
},
{
Name: "create-org",
ShortName: "co",
Description: "Create an org",
//.........這裏部分代碼省略.........
示例2: NewApp
func NewApp(cmdRunner commands.Runner) (app *cli.App, err error) {
helpCommand := cli.Command{
Name: "help",
ShortName: "h",
Description: "Show help",
Usage: fmt.Sprintf("%s help [COMMAND]", cf.Name()),
Action: func(c *cli.Context) {
args := c.Args()
if len(args) > 0 {
cli.ShowCommandHelp(c, args[0])
} else {
showAppHelp(appHelpTemplate, c.App)
}
},
}
cli.HelpPrinter = showAppHelp
cli.AppHelpTemplate = appHelpTemplate
trace.Logger.Printf("\n%s\n%s\n\n", terminal.HeaderColor("VERSION:"), cf.Version)
app = cli.NewApp()
app.Usage = cf.Usage
app.Version = cf.Version
app.Action = helpCommand.Action
app.Commands = []cli.Command{
helpCommand,
{
Name: "api",
Description: "Set or view target api url",
Usage: fmt.Sprintf("%s api [URL]", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("api", c)
},
Flags: []cli.Flag{
cli.BoolFlag{Name: "skip-ssl-validation", Usage: "Please don't"},
},
},
{
Name: "app",
Description: "Display health and status for app",
Usage: fmt.Sprintf("%s app APP", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("app", c)
},
},
{
Name: "apps",
ShortName: "a",
Description: "List all apps in the target space",
Usage: fmt.Sprintf("%s apps", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("apps", c)
},
},
{
Name: "auth",
Description: "Authenticate user non-interactively",
Usage: fmt.Sprintf("%s auth USERNAME PASSWORD\n\n", cf.Name()) +
terminal.WarningColor("WARNING:\n Providing your password as a command line option is highly discouraged\n Your password may be visible to others and may be recorded in your shell history\n\n") +
"EXAMPLE:\n" +
fmt.Sprintf(" %s auth [email protected] \"my password\" (use quotes for passwords with a space)\n", cf.Name()) +
fmt.Sprintf(" %s auth [email protected] \"\\\"password\\\"\" (escape quotes if used in password)", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("auth", c)
},
},
{
Name: "bind-service",
ShortName: "bs",
Description: "Bind a service instance to an app",
Usage: fmt.Sprintf("%s bind-service APP SERVICE_INSTANCE", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("bind-service", c)
},
},
{
Name: "buildpacks",
Description: "List all buildpacks",
Usage: fmt.Sprintf("%s buildpacks", cf.Name()),
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("buildpacks", c)
},
},
{
Name: "create-buildpack",
Description: "Create a buildpack",
Usage: fmt.Sprintf("%s create-buildpack BUILDPACK PATH POSITION [--enable|--disable]", cf.Name()) +
"\n\nTIP:\n" +
" Path should be a zip file, a url to a zip file, or a local directory. Position is an integer, sets priority, and is sorted from lowest to highest.",
Flags: []cli.Flag{
cli.BoolFlag{Name: "enable", Usage: "Enable the buildpack"},
cli.BoolFlag{Name: "disable", Usage: "Disable the buildpack"},
},
Action: func(c *cli.Context) {
cmdRunner.RunCmdByName("create-buildpack", c)
},
},
{
Name: "create-domain",
Description: "Create a domain in an org for later use",
//.........這裏部分代碼省略.........