本文整理汇总了Golang中github.com/codegangsta/cli.App.Commands方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Commands方法的具体用法?Golang App.Commands怎么用?Golang App.Commands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codegangsta/cli.App
的用法示例。
在下文中一共展示了App.Commands方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: loadCommands
func loadCommands(app *cli.App) {
app.Action = mainCmd
app.Flags = []cli.Flag{
cli.StringFlag{"assigned", "", "display issues assigned to <user>. Use '*' for all assigned, or 'none' for all unassigned."},
cli.BoolFlag{"no-trunc", "do not truncate the issue name"},
}
app.Commands = []cli.Command{
{
Name: "alru",
Usage: "Show the Age of the Least Recently Updated issue for this repo. Lower is better.",
Action: alruCmd,
},
{
Name: "repo",
Usage: "List information about the current repository",
Action: repositoryInfoCmd,
},
{
Name: "auth",
Usage: "Add a github token for authentication",
Action: authCmd,
Flags: []cli.Flag{
cli.StringFlag{"add", "", "add new token for authentication"},
},
},
}
}
示例2: setupPingCommand
func setupPingCommand(app *cli.App) {
app.Commands = append(app.Commands, cli.Command{
Name: "ping",
Aliases: []string{"p"},
Usage: "ping the cluster to see if it's available",
Action: ping,
},
)
}
示例3: setupGlobalCommands
func setupGlobalCommands(app *cli.App) {
app.Commands = []cli.Command{
{
Name: "help",
Aliases: []string{"man"},
Usage: "prints this help message",
Action: cli.ShowAppHelp,
},
}
}
示例4: loadCommands
func loadCommands(app *cli.App) {
app.Action = mainCmd
app.Flags = []cli.Flag{
cli.StringFlag{"assigned", "", "display issues assigned to <user>. Use '*' for all assigned, or 'none' for all unassigned."},
cli.StringFlag{"remote", "origin", "git remote to treat as origin"},
cli.BoolFlag{"no-trunc", "do not truncate the issue name"},
cli.IntFlag{"votes", -1, "display the number of votes '+1' filtered by the <number> specified."},
cli.BoolFlag{"vote", "add '+1' to an specific issue."},
}
app.Commands = []cli.Command{
{
Name: "alru",
Usage: "Show the Age of the Least Recently Updated issue for this repo. Lower is better.",
Action: alruCmd,
},
{
Name: "repo",
Usage: "List information about the current repository",
Action: repositoryInfoCmd,
},
{
Name: "take",
Usage: "Assign an issue to your github account",
Action: takeCmd,
Flags: []cli.Flag{
cli.BoolFlag{"overwrite", "overwrites a taken issue"},
},
},
{
Name: "search",
Usage: "Find issues by state and keyword.",
Action: searchCmd,
Flags: []cli.Flag{
cli.StringFlag{"author", "", "Finds issues created by a certain user"},
cli.StringFlag{"assignee", "", "Finds issues that are assigned to a certain user"},
cli.StringFlag{"mentions", "", "Finds issues that mention a certain user"},
cli.StringFlag{"commenter", "", "Finds issues that a certain user commented on"},
cli.StringFlag{"involves", "", "Finds issues that were either created by a certain user, assigned to that user, mention that user, or were commented on by that user"},
cli.StringFlag{"labels", "", "Filters issues based on their labels"},
cli.StringFlag{"state", "", "Filter issues based on whether they’re open or closed"},
},
},
{
Name: "auth",
Usage: "Add a github token for authentication",
Action: authCmd,
Flags: []cli.Flag{
cli.StringFlag{"add", "", "add new token for authentication"},
},
},
}
}
示例5: loadCommands
func loadCommands(app *cli.App) {
// default to listing a service
app.Action = getAction
app.Flags = []cli.Flag{
cli.BoolFlag{"json", "output to json"},
cli.StringFlag{"host", os.Getenv("SKYDNS"), "url to SkyDNS's HTTP endpoints (defaults to env. var. SKYDNS)"},
cli.StringFlag{"dns",
func() string {
if x := os.Getenv("SKYDNS_DNS"); x != "" {
if strings.HasPrefix(x, "http") {
return x
}
return "http://" + x // default to http for now
}
return "127.0.0.1:53"
}(), "DNS port of SkyDNS's DNS endpoint (defaults to env. var. SKYDNS_DNS)"},
cli.StringFlag{"domain",
func() string {
if x := os.Getenv("SKYDNS_DOMAIN"); x != "" {
return x
}
return "skydns.local"
}(), "DNS domain of SkyDNS (defaults to env. var. SKYDNS_DOMAIN))"},
cli.StringFlag{"secret", "", "secret to authenticate with"},
}
app.Commands = []cli.Command{
{
Name: "list",
Usage: "list a service from skydns",
Action: getAction,
Flags: []cli.Flag{cli.BoolFlag{"d", "use DNS instead of HTTP"}},
},
{
Name: "add",
Usage: "add a new service to skydns",
Action: addAction,
},
{
Name: "delete",
Usage: "delete a service from skydns",
Action: deleteAction,
},
{
Name: "update",
Usage: "update a service's ttl in skydns",
Action: updateAction,
},
}
}
示例6: setCommands
func setCommands(app *cli.App) {
commands := []cli.Command{}
// TODO: Automaticaly load the commands based on the cmd directory content.
commands = append(commands, cmd.Init())
commands = append(commands, cmd.List())
commands = append(commands, cmd.On())
commands = append(commands, cmd.Log())
commands = append(commands, cmd.Stop())
commands = append(commands, cmd.Done())
commands = append(commands, cmd.Status())
app.Commands = commands
}
示例7: main
func main() {
var app *cli.App
app = cli.NewApp()
app.Name = APP_NAME
app.Version = APP_VER
app.Usage = "email for mail sending, or web or none for run web interface!"
app.Commands = []cli.Command{
task.CmdWeb,
task.CmdEmail,
}
app.Flags = append(app.Flags, []cli.Flag{}...)
app.Run(os.Args)
}
示例8: loadCommands
func loadCommands(app *cli.App) {
// default to listing a service
app.Action = getAction
app.Flags = []cli.Flag{
cli.BoolFlag{"json", "output to json"},
cli.StringFlag{"host", os.Getenv("SKYDNS"), "url to SkyDNS's HTTP endpoints (defaults to env. var. SKYDNS)"},
cli.StringFlag{"dnsport",
func() string {
x := os.Getenv("SKYDNS_DNSPORT")
if x == "" {
x = "53"
}
return x
}(), "DNS port of SkyDNS's DNS endpoint (defaults to env. var. SKYDNS_DNSPORT or 53)"},
cli.StringFlag{"dnsdomain",
func() string {
x := os.Getenv("SKYDNS_DNSDOMAIN")
if x == "" {
x = "skydns.local"
}
return x
}(), "DNS domain of SkyDNS (defaults to env. var. SKYDNS_DNSDOMAIN or skydns.local)"},
cli.StringFlag{"secret", "", "secret to authenticate with"},
}
app.Commands = []cli.Command{
{
Name: "list",
Usage: "list a service from skydns",
Action: getAction,
Flags: []cli.Flag{cli.BoolFlag{"d", "use DNS instead of HTTP"}},
},
{
Name: "add",
Usage: "add a new service to skydns",
Action: addAction,
},
{
Name: "delete",
Usage: "delete a service from skydns",
Action: deleteAction,
},
{
Name: "update",
Usage: "update a service's ttl in skydns",
Action: updateAction,
},
}
}
示例9: setCommands
// Set application commands
func setCommands(app *cli.App, config *configuration) {
app.Commands = []cli.Command{
{
Name: "checkout",
Aliases: []string{"co"},
Usage: "Checkout branch",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "b",
Usage: "Create new branch while checkout",
},
},
Action: func(c *cli.Context) {
valid := validateConfiguration(config)
if !valid {
fmt.Println(errorDecorator("Please provide valid configuration"))
os.Exit(1)
}
checkoutBranch(c, config)
},
},
{
Name: "version",
Aliases: []string{"v"},
Usage: "Get version issues",
Action: func(c *cli.Context) {
valid := validateConfiguration(config)
if !valid {
fmt.Println(errorDecorator("Please provide valid configuration"))
os.Exit(1)
}
getVersionIssues(c, config)
},
},
{
Name: "description",
Aliases: []string{"d"},
Usage: "Show issue description",
Action: func(c *cli.Context) {
valid := validateConfiguration(config)
if !valid {
fmt.Println(errorDecorator("Please provide valid configuration"))
os.Exit(1)
}
showIssueDetails(c, config)
},
},
}
}
示例10: Register
//import "encoding/json"
// maybe pass in a points to Commands, so we can register
// subcommands? Or a register module to do the registering.
func Register(app *cli.App) string {
app.Commands = []cli.Command{
{
Name: "cloudformation",
Subcommands: []cli.Command{
{
Name: "follow-stack-events",
Usage: "NAME...",
Action: followStackEvents,
},
},
},
}
return "Finished"
}
示例11: AddToCLI
func AddToCLI(a *cli.App) {
commands := []cli.Command{
{
Name: "ec2",
Usage: "find EC2 instances that match a regex",
Aliases: []string{"e"},
Subcommands: []cli.Command{
{
Name: "match",
Aliases: []string{"m"},
Usage: "find EC2 instances that match a regex",
Action: Match,
},
},
},
}
a.Commands = append(a.Commands, commands...)
}
示例12: setupCommands
func setupCommands(app *cli.App) {
app.Commands = []cli.Command{
{
Name: "signature",
Aliases: []string{"s"},
Usage: "Signature generate use blake2 algorithm\n" +
" -b, --block-size=BYTES Signature block size\n" +
" -s, --sum-size=BYTES Set signature strength\n",
Flags: []cli.Flag{
cli.IntFlag{
Name: "block-size,b",
Value: 2048,
Usage: "Set signature block size",
},
cli.IntFlag{
Name: "sum-size,s",
Value: 32,
Usage: "Set signature strong checksum strength, 32 or 64",
},
},
Action: doSign,
},
{
Name: "delta",
Aliases: []string{"d"},
Usage: "Delta-encoding options:\n" +
" -b, --block-size=BYTES Signature block size\n" +
" -s, --sum-size=BYTES Set signature strength\n",
Action: doDelta,
},
{
Name: "patch",
Aliases: []string{"p"},
Usage: "complete a task on the list\n" +
" -b, --block-size=BYTES Signature block size\n" +
" -s, --sum-size=BYTES Set signature strength\n",
Action: doPatch,
},
}
}
示例13: initCommands
func initCommands(app *gcli.App) {
app.Commands = []gcli.Command{
createAlertCommand(),
getAlertCommand(),
attachFileCommand(),
acknowledgeCommand(),
renotifyCommand(),
takeOwnershipCommand(),
assignOwnerCommand(),
addTeamCommand(),
addRecipientCommand(),
addTagsCommand(),
addNoteCommand(),
executeActionCommand(),
closeAlertCommand(),
deleteAlertCommand(),
heartbeatCommand(),
enableCommand(),
disableCommand(),
}
}
示例14: setupClusterCommand
func setupClusterCommand(app *cli.App) {
app.Commands = append(
app.Commands,
cli.Command{
Name: "cluster",
Aliases: []string{"c"},
Usage: "get information about the connected cluster",
Action: cli.ShowSubcommandHelp,
HideHelp: true,
Subcommands: []cli.Command{
cli.Command{
Name: "health",
Aliases: []string{"h"},
Usage: "get health information about the cluster",
Action: getClusterHealth,
},
cli.Command{
Name: "stats",
Aliases: []string{"s"},
Usage: "get cluster-wide statistics, including indices, storage and nodes",
Action: getClusterStats,
},
cli.Command{
Name: "nodes",
Aliases: []string{"n"},
Usage: "get information on the nodes in the cluster",
Action: getClusterNodes,
},
cli.Command{
Name: "update",
Aliases: []string{"u"},
Usage: "update the cluster settings via JSON",
Description: "esu cluster update [PATH] -- Where PATH is a JSON document to update with. Alternatively, JSON can be piped into this command",
Action: putClusterSettings,
},
},
},
)
}
示例15:
Expect(fakeExitHandler.ExitCalledWith).To(Equal([]int{1}))
})
})
Describe("App.Before", func() {
Context("when running the target command", func() {
It("does not verify the current target", func() {
cliConfig.SetTarget("my-lattice.example.com")
Expect(cliConfig.Save()).To(Succeed())
commandRan := false
cliApp.Commands = []cli.Command{
cli.Command{
Name: "target",
Action: func(ctx *cli.Context) {
commandRan = true
},
},
}
Expect(cliApp.Run([]string{"ltc", "target"})).To(Succeed())
Expect(commandRan).To(BeTrue())
Expect(fakeTargetVerifier.VerifyTargetCallCount()).To(Equal(0))
})
})
Context("when running the help command", func() {
It("does not verify the current target", func() {
cliConfig.SetTarget("my-lattice.example.com")
Expect(cliConfig.Save()).To(Succeed())