示例#1
0
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.BoolFlag{"closed", "display closed prs"},
		cli.BoolFlag{"new", "display prs opened in the last 24 hours"},
	}
	// 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"},
			},
		},
		{
			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,
		},
	}
}
示例#2
0
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"},
			},
		},
	}
}
示例#3
0
func describeApp(app *cli.App, version string) {
	app.Name = "init-exporter"
	app.Usage = "exports services described by Procfile to systemd"
	app.Version = version

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "n, appname",
			Usage: "Application name (This name only affects the names of generated files)",
		},
		cli.BoolFlag{
			Name:  "c, uninstall",
			Usage: "Remove scripts and helpers for a particular application",
		},
		cli.StringFlag{
			Name:  "config",
			Value: defaultConfigPath,
			Usage: "path to configuration file",
		},
		cli.StringFlag{
			Name:  "p, procfile",
			Usage: "path to procfile",
		},
		cli.StringFlag{
			Name:  "f, format",
			Usage: "Format of init files (upstart | systemd)",
		},
	}
}
示例#4
0
文件: debug.go 项目: Byron/godi
func AddAdditinalFlags(a *cli.App) {
	// nop
	a.Flags = append(a.Flags,
		cli.StringFlag{memProfileFlagName, "", "If set, the given file will contain the memory profile of the previous run"},
		cli.StringFlag{cpuProfileFlagName, "", "If set, the given file will contain the CPU profile of the previous run"},
	)
}
func SetupCPUProfile(app *cli.App) {
	app.Flags = append(app.Flags, cli.StringFlag{
		Name:   "cpuprofile",
		Usage:  "write cpu profile to file",
		EnvVar: "CPU_PROFILE",
	})

	appBefore := app.Before
	appAfter := app.After

	app.Before = func(c *cli.Context) error {
		if cpuProfile := c.String("cpuprofile"); cpuProfile != "" {
			f, err := os.Create(cpuProfile)
			if err != nil {
				return err
			}
			pprof.StartCPUProfile(f)
		}

		if appBefore != nil {
			return appBefore(c)
		}
		return nil
	}

	app.After = func(c *cli.Context) error {
		pprof.StopCPUProfile()

		if appAfter != nil {
			return appAfter(c)
		}
		return nil
	}
}
示例#6
0
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"},
			},
		},
	}
}
示例#7
0
文件: main.go 项目: johansenj/skydns
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,
		},
	}
}
示例#8
0
文件: qs.go 项目: qSlide/qslide
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)
}
示例#9
0
文件: main.go 项目: rpeterson/skydns
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,
		},
	}
}
示例#10
0
文件: cliconfig.go 项目: G5/gog5auth
// RegisterServiceToServiceFlags accepts an App to register flags that gog5auth
// accepts. This registers the flags needed for service-to-service auth. Should
// be paired with InitializeFromContext.
func RegisterServiceToServiceFlags(app *cli.App) {
	serviceToServiceIsRegistered = true
	fs := []cli.Flag{
		cli.StringFlag{
			Name:   UsernameFlag,
			Usage:  "G5 Auth Service Account Username",
			EnvVar: "G5_AUTH_USERNAME",
		},
		cli.StringFlag{
			Name:   PasswordFlag,
			Usage:  "G5 Auth Service Account Password",
			EnvVar: "G5_AUTH_PASSWORD",
		},
	}
	app.Flags = append(app.Flags, fs...)
}
示例#11
0
文件: app.go 项目: rodaine/esu
func setupGlobalFlags(app *cli.App) {
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "host, h",
			Usage:  "the Elasticsearch node host",
			Value:  DefaultHost,
			EnvVar: "ESU_HOST",
		},
		cli.StringFlag{
			Name:   "port, p",
			Usage:  "the Elasticsearch node port",
			Value:  DefaultPort,
			EnvVar: "ESU_PORT",
		},
		cli.BoolFlag{
			Name:   "ssl, s",
			Usage:  "connect to the Elasticsearch node via SSL (HTTPS)",
			EnvVar: "ESU_SSL",
		},
	}
}
示例#12
0
文件: cliconfig.go 项目: G5/gog5auth
// RegisterStandardFlags accepts an App to register flags that gog5auth
// accepts. This registers the typical flags for application and auth server.
// Should be paired with InitializeFromContext.
func RegisterStandardFlags(app *cli.App) {
	fs := []cli.Flag{
		cli.StringFlag{
			Name:   ClientIDFlag,
			Usage:  "G5 Auth application ID",
			EnvVar: "G5_AUTH_CLIENT_ID",
		},
		cli.StringFlag{
			Name:   ClientSecretFlag,
			Usage:  "G5 Auth application secret",
			EnvVar: "G5_AUTH_CLIENT_SECRET",
		},
		cli.StringFlag{
			Name:   EndpointFlag,
			Value:  client.Endpoint,
			Usage:  "G5 Auth endpoint",
			EnvVar: "G5_AUTH_ENDPOINT",
		},
	}
	app.Flags = append(app.Flags, fs...)
}
示例#13
0
文件: jit.go 项目: Rentlio/jit
// Set global flags to App
func setGlobalFlags(app *cli.App, config *configuration) {
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "username, u",
			Usage:       "Username for jira basic auth",
			EnvVar:      "JIRA_USERNAME",
			Value:       config.Username,
			Destination: &config.Username,
		},
		cli.StringFlag{
			Name:        "password, p",
			Usage:       "Password for jira Basic Auth",
			EnvVar:      "JIRA_PASSWORD",
			Value:       config.Password,
			Destination: &config.Password,
		},
		cli.StringFlag{
			Name:        "url",
			Usage:       "Base url for your jira api",
			EnvVar:      "JIRA_URL",
			Value:       config.URL,
			Destination: &config.URL,
		},
		cli.StringFlag{
			Name:        "project",
			Usage:       "Jira project code. If specified only issues ID can be used in commands.",
			EnvVar:      "JIRA_PROJECT_CODE",
			Value:       config.ProjectCode,
			Destination: &config.ProjectCode,
		},
		cli.StringFlag{
			Name:        "working-branch, wb",
			Usage:       "Git working branch. If set, checkout command without ID will checkout this branch.",
			EnvVar:      "JIT_WORKING_BRANCH",
			Value:       config.WorkingBranch,
			Destination: &config.WorkingBranch,
		},
	}
}
示例#14
0
文件: config.go 项目: koron/kii-cli
func setupFlags(app *cli.App) {
	app.Flags = []cli.Flag{
		cli.StringFlag{"app-id", "", "AppID"},
		cli.StringFlag{"app-key", "", "AppKey"},
		cli.StringFlag{"client-id", "", "ClientID"},
		cli.StringFlag{"client-secret", "", "ClientSecret"},
		cli.StringFlag{"site", "", "us,jp,cn,sg"},
		cli.StringFlag{"endpoint-url", "", "Site URL"},
		cli.BoolFlag{"verbose", "Verbosely"},
		cli.StringFlag{"profile", "default", "Profile name for ~/.kii/config"},
	}

	app.Before = func(c *cli.Context) error {
		profile := c.GlobalString("profile")
		inifile := loadIniFile()
		if profile != "default" && len((*inifile)[profile]) == 0 {
			print(fmt.Sprintf("profile %s is not found in ~/.kii/config\n", profile))
			os.Exit(ExitMissingParams)
		}

		get := func(name string) string {
			v, _ := inifile.Get(profile, name)
			return v
		}
		globalConfig = &GlobalConfig{
			pickup(c.GlobalString("app-id"), os.ExpandEnv("${KII_APP_ID}"), get("app_id")),
			pickup(c.GlobalString("app-key"), os.ExpandEnv("${KII_APP_KEY}"), get("app_key")),
			pickup(c.GlobalString("client-id"), os.ExpandEnv("${KII_CLIENT_ID}"), get("client_id")),
			pickup(c.GlobalString("client-secret"), os.ExpandEnv("${KII_CLIENT_SECRET}"), get("client_secret")),
			pickup(c.GlobalString("site"), os.ExpandEnv("${KII_SITE}"), get("site")),
			pickup(c.GlobalString("endpoint-url"), os.ExpandEnv("${KII_ENDPOINT_URL}"), get("endpoint_url")),
		}
		if c.Bool("verbose") {
			logger = &_Logger{}
		}
		return nil
	}
}
func SetupLogLevelOptions(app *cli.App) {
	newFlags := []cli.Flag{
		cli.BoolFlag{
			Name:   "debug",
			Usage:  "debug mode",
			EnvVar: "DEBUG",
		},
		cli.StringFlag{
			Name:  "log-level, l",
			Value: "info",
			Usage: "Log level (options: debug, info, warn, error, fatal, panic)",
		},
	}
	app.Flags = append(app.Flags, newFlags...)

	appBefore := app.Before
	// logs
	app.Before = func(c *cli.Context) error {
		log.SetOutput(os.Stderr)
		level, err := log.ParseLevel(c.String("log-level"))
		if err != nil {
			log.Fatalf(err.Error())
		}
		log.SetLevel(level)

		// If a log level wasn't specified and we are running in debug mode,
		// enforce log-level=debug.
		if !c.IsSet("log-level") && !c.IsSet("l") && c.Bool("debug") {
			log.SetLevel(log.DebugLevel)
		}

		if appBefore != nil {
			return appBefore(c)
		} else {
			return nil
		}
	}
}
示例#16
0
文件: cli.go 项目: TechMantra/focus
func setFlags(app *cli.App) {
	app.Flags = []cli.Flag{}
}
示例#17
0
文件: commands.go 项目: rm3l/gordon
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"},
			},
		},
		{
			Name:   "drop",
			Usage:  "Give up ownership of a pull request assigned to you",
			Action: dropCmd,
			Flags:  []cli.Flag{},
		},
		{
			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"},
			},
		},
	}
}
示例#18
0
文件: commands.go 项目: askb/gordon
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"},
			},
		},
	}
}
示例#19
0
文件: commands.go 项目: rogaha/gordon
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"},
			},
		},
	}
}
示例#20
0
文件: flag.go 项目: DevinciHQ/ahoy
func overrideFlags(app *cli.App) {
	app.Flags = globalFlags
	app.HideVersion = true
	app.HideHelp = true
}