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


Golang App.Flags方法代码示例

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


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

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

示例2: describeApp

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)",
		},
	}
}
开发者ID:miros,项目名称:init-exporter,代码行数:29,代码来源:init-exporter.go

示例3: AddAdditinalFlags

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"},
	)
}
开发者ID:Byron,项目名称:godi,代码行数:7,代码来源:debug.go

示例4: SetupCPUProfile

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
	}
}
开发者ID:bssthu,项目名称:gitlab-ci-multi-runner,代码行数:34,代码来源:cpuprofile.go

示例5: 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

示例6: 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

示例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)
}
开发者ID:qSlide,项目名称:qslide,代码行数:14,代码来源:qs.go

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

示例9: RegisterServiceToServiceFlags

// 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...)
}
开发者ID:G5,项目名称:gog5auth,代码行数:19,代码来源:cliconfig.go

示例10: setupGlobalFlags

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",
		},
	}
}
开发者ID:rodaine,项目名称:esu,代码行数:21,代码来源:app.go

示例11: RegisterStandardFlags

// 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...)
}
开发者ID:G5,项目名称:gog5auth,代码行数:24,代码来源:cliconfig.go

示例12: setGlobalFlags

// 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,
		},
	}
}
开发者ID:Rentlio,项目名称:jit,代码行数:40,代码来源:jit.go

示例13: setupFlags

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
	}
}
开发者ID:koron,项目名称:kii-cli,代码行数:38,代码来源:config.go

示例14: SetupLogLevelOptions

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
		}
	}
}
开发者ID:zhangxq5012,项目名称:gitlab-ci-multi-runner,代码行数:38,代码来源:log_level.go

示例15: setFlags

func setFlags(app *cli.App) {
	app.Flags = []cli.Flag{}
}
开发者ID:TechMantra,项目名称:focus,代码行数:3,代码来源:cli.go


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