当前位置: 首页>>代码示例>>Golang>>正文


Golang App.Action方法代码示例

本文整理汇总了Golang中github.com/codegangsta/cli.App.Action方法的典型用法代码示例。如果您正苦于以下问题:Golang App.Action方法的具体用法?Golang App.Action怎么用?Golang App.Action使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/codegangsta/cli.App的用法示例。


在下文中一共展示了App.Action方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: setDefaultAction

func setDefaultAction(app *cli.App) {
	app.Action = func(c *cli.Context) {
		// TODO: If in a focused directory show the list of tasks
		// If not show the app help or some basic direction to init it
		cli.ShowAppHelp(c)
	}
}
开发者ID:TechMantra,项目名称:focus,代码行数:7,代码来源:cli.go

示例2: 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"},
			},
		},
	}
}
开发者ID:jamtur01,项目名称:pulls,代码行数:29,代码来源:commands.go

示例3: 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"},
			},
		},
	}
}
开发者ID:rjnagal,项目名称:gordon,代码行数:54,代码来源:commands.go

示例4: 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,
		},
	}
}
开发者ID:johansenj,项目名称:skydns,代码行数:51,代码来源:main.go

示例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{"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,
		},
	}
}
开发者ID:rpeterson,项目名称:skydns,代码行数:50,代码来源:main.go

示例6: mainLoop

func mainLoop(app *cli.App) {
	app.Action = func(c *cli.Context) {
		//host := c.GlobalString("host")
		cfg, err := getConfig(c)
		if err != nil {
			log.WithFields(log.Fields{
				"file:": "main.go",
				"func:": "main",
				"line:": 74,
			}).Fatal("getConfig return error")
			return
		}
		svc := OnionService{}

		if err = svc.Run(cfg); err != nil {
			log.Fatal(err)
		}
	}
}
开发者ID:mingderwang,项目名称:onion,代码行数:19,代码来源:main.go

示例7:

			It("defaults the version", func() {
				Expect(cliApp).NotTo(BeNil())
				Expect(cliApp.Version).To(Equal("development (not versioned) (diego unknown)"))
			})
		})

		Describe("App.Action", func() {
			Context("when ltc is run without argument(s)", func() {
				It("prints app help", func() {
					cli.AppHelpTemplate = "HELP_TEMPLATE"
					flagSet := flag.NewFlagSet("flag_set", flag.ContinueOnError)
					flagSet.Parse([]string{})
					testContext := cli.NewContext(cliApp, flagSet, nil)

					cliApp.Action(testContext)

					Expect(outputBuffer).To(test_helpers.Say("ltc - Command line interface for Lattice."))
				})
			})

			Context("when ltc is run with argument(s)", func() {
				It("prints unknown command message", func() {
					flagSet := flag.NewFlagSet("flag_set", flag.ContinueOnError)
					flagSet.Parse([]string{"one_arg"})
					testContext := cli.NewContext(cliApp, flagSet, nil)

					cliApp.Action(testContext)

					Expect(outputBuffer).To(test_helpers.Say("ltc: 'one_arg' is not a registered command. See 'ltc help'"))
				})
开发者ID:edwardt,项目名称:lattice,代码行数:30,代码来源:cli_app_factory_test.go

示例8: loadCommands

func loadCommands(app *cli.App) {
	// Add top level flags and commands
	app.Action = mainCmd

	app.Flags = []cli.Flag{
		cli.StringFlag{"remote", "origin", "git remote to treat as origin"},
	}

	// Filters modify what type of pr to display
	filters := []cli.Flag{
		cli.BoolFlag{"no-merge", "display only prs that cannot be merged"},
		cli.BoolFlag{"lgtm", "display the number of LGTM"},
		cli.StringFlag{"state", "open", "display prs based on their state"},
		cli.BoolFlag{"new", "display prs opened in the last 24 hours"},
		cli.BoolFlag{"mine", "display only PRs I care about based on the MAINTAINERS files"},
		cli.StringFlag{"maintainer", "", "display only PRs a maintainer cares about based on the MAINTAINERS files"},
		cli.StringFlag{"sort", "updated", "sort the prs by (created, updated, popularity, long-running)"},
		cli.StringFlag{"assigned", "", "display only prs assigned to a user"},
		cli.BoolFlag{"unassigned", "display only unassigned prs"},
		cli.StringFlag{"dir", "", "display only prs that touch this dir"},
		cli.StringFlag{"extension", "", "display only prs that have files with this extension (no dot)"},
		cli.BoolFlag{"cleanup", "display only cleanup prs"},
	}
	app.Flags = append(app.Flags, filters...)

	// Options modify how to display prs
	options := []cli.Flag{
		cli.BoolFlag{"no-trunc", "don't truncate pr name"},
		cli.StringFlag{"user", "", "display only prs from <user>"},
		cli.StringFlag{"comment", "", "add a comment to the pr"},
	}
	app.Flags = append(app.Flags, options...)

	// Add subcommands
	app.Commands = []cli.Command{
		{
			Name:   "repo",
			Usage:  "List information about the current repository",
			Action: repositoryInfoCmd,
		},
		{
			Name:   "comment",
			Usage:  "Leave a comment on a pull request",
			Action: commentCmd,
		},
		{
			Name:   "comments",
			Usage:  "Show comments on a pull request",
			Action: commentsCmd,
		},
		{
			Name:   "auth",
			Usage:  "Add a github token for authentication",
			Action: authCmd,
			Flags: []cli.Flag{
				cli.StringFlag{"add", "", "add new token for authentication"},
				cli.StringFlag{"user", "", "add github user name"},
			},
		},
		{
			Name:   "alru",
			Usage:  "Show the Age of the Least Recently Updated pull request for this repo. Lower is better.",
			Action: alruCmd,
		},
		{
			Name:   "merge",
			Usage:  "Merge a pull request",
			Action: mergeCmd,
			Flags: []cli.Flag{
				cli.StringFlag{"m", "", "commit message for merge"},
				cli.BoolFlag{"force", "merge a pull request that has not been approved"},
			},
		},
		{
			Name:   "close",
			Usage:  "Close a pull request without merging it",
			Action: closeCmd,
			Flags:  []cli.Flag{},
		},
		{
			Name:   "checkout",
			Usage:  "Checkout a pull request into your local repo",
			Action: checkoutCmd,
		},
		{
			Name:   "send",
			Usage:  "Send a new pull request, or overwrite an existing one",
			Action: sendCmd,
		},
		{
			Name:   "approve",
			Usage:  "Approve a pull request by adding LGTM to the comments",
			Action: approveCmd,
		},
		{
			Name:   "take",
			Usage:  "Assign a pull request to your github account",
			Action: takeCmd,
			Flags: []cli.Flag{
				cli.BoolFlag{"steal", "steal the pull request from its current owner"},
//.........这里部分代码省略.........
开发者ID:rm3l,项目名称:gordon,代码行数:101,代码来源:commands.go

示例9: loadCommands

func loadCommands(app *cli.App) {
	// Add top level flags and commands
	app.Action = mainCmd

	// Filters modify what type of pr to display
	filters := []cli.Flag{
		cli.BoolFlag{"no-merge", "display only prs that cannot be merged"},
		cli.BoolFlag{"lgtm", "display the number of LGTM"},
		cli.StringFlag{"state", "open", "display prs based on their state"},
		cli.BoolFlag{"new", "display prs opened in the last 24 hours"},
		cli.BoolFlag{"mine", "display only PRs I care about based on the MAINTAINERS files"},
		cli.StringFlag{"sort", "updated", "sort the prs by (created, updated, popularity, long-running)"},
	}
	// Options modify how to display prs
	options := []cli.Flag{
		cli.BoolFlag{"no-trunc", "don't truncate pr name"},
		cli.StringFlag{"user", "", "display only prs from <user>"},
		cli.StringFlag{"comment", "", "add a comment to the pr"},
	}
	app.Flags = append(filters, options...)

	// Add subcommands
	app.Commands = []cli.Command{
		{
			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"},
				cli.StringFlag{"user", "", "add github user name"},
			},
		},
		{
			Name:   "alru",
			Usage:  "Show the Age of the Least Recently Updated pull request for this repo. Lower is better.",
			Action: alruCmd,
		},
		{
			Name:   "merge",
			Usage:  "Merge a pull request",
			Action: mergeCmd,
			Flags: []cli.Flag{
				cli.StringFlag{"m", "", "commit message for merge"},
				cli.BoolFlag{"force", "merge a pull request that has not been approved"},
			},
		},
		{
			Name:   "checkout",
			Usage:  "Checkout a pull request into your local repo",
			Action: checkoutCmd,
		},
		{
			Name:   "approve",
			Usage:  "Approve a pull request by adding LGTM to the comments",
			Action: approveCmd,
		},
		{
			Name:   "diff",
			Usage:  "Print the patch submitted by a pull request",
			Action: showCmd,
		},
		{
			Name:   "reviewers",
			Usage:  "Use the hierarchy of MAINTAINERS files to list who should review a pull request",
			Action: reviewersCmd,
		},
		{
			Name:   "contributors",
			Usage:  "Show the contributors list with additions, deletions, and commit counts. Default: sorted by Commits",
			Action: contributorsCmd,
			Flags: []cli.Flag{
				cli.BoolFlag{"additions", "sort by additions"},
				cli.BoolFlag{"deletions", "sort by deletions"},
				cli.BoolFlag{"commits", "sort by commits"},
				cli.IntFlag{"top", 10, "top N contributors"},
			},
		},
	}
}
开发者ID:rogaha,项目名称:gordon,代码行数:84,代码来源:commands.go

示例10: loadCommands

func loadCommands(app *cli.App) {
	app.Action = mainCmd

	app.Flags = []cli.Flag{
		cli.StringFlag{Name: "assigned", Value: "", Usage: "display issues assigned to <user>. Use '*' for all assigned, or 'none' for all unassigned."},
		cli.StringFlag{Name: "remote", Value: gordon.GetDefaultGitRemote(), Usage: "git remote to treat as origin"},
		cli.StringFlag{Name: "milestone", Value: "", Usage: "display issues inside a particular <milestone>."},
		cli.BoolFlag{Name: "no-trunc", Usage: "do not truncate the issue name"},
		cli.BoolFlag{Name: "verbose", Usage: "show more verbose output on actions"},
		cli.IntFlag{Name: "votes", Value: -1, Usage: "display the number of votes '+1' filtered by the <number> specified."},
		cli.BoolFlag{Name: "vote", Usage: "add '+1' to an specific issue."},
		cli.BoolFlag{Name: "proposals", Usage: "Only show proposal issues"},
	}

	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{Name: "overwrite", Usage: "overwrites a taken issue"},
			},
		},
		{
			Name:        "close",
			Usage:       "Close an issue",
			Description: "Provide the issue number for issue(s) to close for this repository",
			Action:      closeCmd,
			Flags:       []cli.Flag{},
		},
		{
			Name:   "search",
			Usage:  "Find issues by state and keyword.",
			Action: searchCmd,
			Flags: []cli.Flag{
				cli.StringFlag{Name: "author", Value: "", Usage: "Finds issues created by a certain user"},
				cli.StringFlag{Name: "assignee", Value: "", Usage: "Finds issues that are assigned to a certain user"},
				cli.StringFlag{Name: "mentions", Value: "", Usage: "Finds issues that mention a certain user"},
				cli.StringFlag{Name: "commenter", Value: "", Usage: "Finds issues that a certain user commented on"},
				cli.StringFlag{Name: "involves", Value: "", Usage: "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{Name: "labels", Value: "", Usage: "Filters issues based on their labels"},
				cli.StringFlag{Name: "state", Value: "", Usage: "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{Name: "add", Value: "", Usage: "add new token for authentication"},
			},
		},
	}
}
开发者ID:askb,项目名称:gordon,代码行数:64,代码来源:commands.go


注:本文中的github.com/codegangsta/cli.App.Action方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。