本文整理汇总了Golang中github.com/urfave/cli.NewApp函数的典型用法代码示例。如果您正苦于以下问题:Golang NewApp函数的具体用法?Golang NewApp怎么用?Golang NewApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewApp函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
app := cli.NewApp()
app.Name = appName
app.Usage = "Eleant static website generator"
app.Authors = authors
app.Version = version
app.Commands = []cli.Command{
cli.Command{
Name: "build",
ShortName: "b",
Usage: "build site",
Description: "build site",
Action: build,
Flags: buildFlags(),
},
cli.Command{
Name: "serve",
ShortName: "s",
Usage: "builds and serves the project",
Description: "serves site",
Action: serve,
Flags: buildFlags(),
},
}
app.Run(os.Args)
}
开发者ID:gernest,项目名称:bongo,代码行数:26,代码来源:main.go
示例2: getApp
func getApp() *cli.App {
app := cli.NewApp()
app.Name = "gobot"
app.Usage = "a web crawler written in Go"
app.Version = "0.0.1"
app.Commands = []cli.Command{
{
Name: "crawl",
Aliases: []string{"c"},
Usage: "crawl a domain",
Flags: []cli.Flag{
cli.StringFlag{
Name: "domain, d",
Usage: "`DOMAIN` to crawl",
},
},
Action: func(c *cli.Context) error {
dmn := c.String("domain")
url, err := url.Parse(fmt.Sprintf("http://%s/", dmn))
if err != nil {
log.Fatal(err)
}
sm, err := crawler.Crawl(*url)
if err != nil {
log.Fatal(err)
}
fmt.Printf("%s\n", sm)
return nil
},
},
}
return app
}
开发者ID:RBeaudoin,项目名称:gobot,代码行数:34,代码来源:main.go
示例3: main
func main() {
logger := log.NewLogfmtLogger(os.Stderr)
logger = log.NewContext(logger).With("ts", log.DefaultTimestampUTC)
err := godotenv.Load()
if err != nil {
logger.Log("level", "fatal", "err", err)
}
config := &Config{
Addr: os.Getenv("ADDR"),
DSN: os.Getenv("DSN"),
}
db, err := gorm.Open("postgres", config.DSN)
if err != nil {
panic(err)
}
app := cli.NewApp()
app.Commands = []cli.Command{{
Name: "serve",
Action: serve(logger, config, db),
}}
if err := app.Run(os.Args); err != nil {
logger.Log("level", "fatal", "err", err)
}
}
开发者ID:MetalMatze,项目名称:Krautreporter-API,代码行数:31,代码来源:api.go
示例4: main
func main() {
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Author = "Manfred Touron"
app.Email = "https://github.com/moul/advanced-ssh-config"
app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
app.Usage = "advanced ssh config"
app.EnableBashCompletion = true
app.BashComplete = BashComplete
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "config, c",
EnvVar: "ASSH_CONFIG",
Value: "~/.ssh/assh.yml",
Usage: "Location of config file",
},
cli.BoolFlag{
Name: "debug, D",
EnvVar: "ASSH_DEBUG",
Usage: "Enable debug mode",
},
cli.BoolFlag{
Name: "verbose, V",
Usage: "Enable verbose mode",
},
}
app.Before = hookBefore
app.Commands = commands.Commands
app.Run(os.Args)
}
开发者ID:moul,项目名称:advanced-ssh-config,代码行数:34,代码来源:main.go
示例5: main
func main() {
if setting.RunMode == "prod" {
log.SetFormatter(&log.JSONFormatter{})
log.SetOutput(os.Stderr)
}
app := cli.NewApp()
app.Name = setting.AppName
app.Usage = setting.Usage
app.Version = setting.Version
app.Author = setting.Author
app.Email = setting.Email
app.Commands = []cli.Command{
cmd.CmdWeb,
cmd.CmdDatabase,
cmd.CmdOSS,
cmd.CmdMonitor,
cmd.CmdClient,
}
app.Flags = append(app.Flags, []cli.Flag{}...)
app.Run(os.Args)
}
开发者ID:pombredanne,项目名称:dockyard,代码行数:25,代码来源:main.go
示例6: main
func main() {
app := cc.NewApp()
app.Name = "recause"
app.Usage = "Simple log management server that receives logs in GELF format"
app.Version = "0.0.4"
app.Authors = []cc.Author{
{
Name: "Nikita Vershinin",
Email: "[email protected]",
},
}
app.Flags = []cc.Flag{
cc.StringFlag{
Name: "config, c",
Value: "/etc/recause/config.cfg",
Usage: "path to the configuration file",
},
}
app.Action = actionRun
err := app.Run(os.Args)
if err != nil {
fmt.Fprintf(os.Stderr, "Unhandled error occurred while running application: %v\n", err)
}
}
开发者ID:endeveit,项目名称:recause,代码行数:27,代码来源:main.go
示例7: main
func main() {
app := cli.NewApp()
app.Name = "ionblogbuilder"
app.Flags = []cli.Flag{
cli.IntFlag{
Name: "webport, P",
Value: 80,
Usage: "The webserver port",
},
cli.IntFlag{
Name: "port, p",
Value: 5566,
Usage: "The port github will use to send webhooks",
EnvVar: "PORT,IONBLOG_PORT",
},
cli.StringFlag{
Name: "secret, s",
Usage: "Github secret key",
EnvVar: "IONBLOG_SECRET",
},
cli.StringFlag{
Name: "output, o",
Usage: "Output directory",
EnvVar: "IONBLOG_OUTPUT",
},
}
app.Action = IonblogServerAction
app.Run(os.Args)
}
开发者ID:ionrock,项目名称:ionblogbuilder,代码行数:31,代码来源:main.go
示例8: main
func main() {
app := cli.NewApp()
app.Name = "bch"
app.Usage = "Generate and verify bcrypt password hashes"
app.Commands = []cli.Command{
{
Name: "hash",
Usage: "Generate bcrypt password hash",
Flags: []cli.Flag{
cli.IntFlag{
Name: "factor, f",
Value: 12,
Usage: "work factor",
},
},
Action: hash,
},
{
Name: "verify",
Usage: "Verify given hash against entered password",
ArgsUsage: "[hash]",
Action: verify,
},
}
app.Run(os.Args)
}
开发者ID:cemcatik,项目名称:bch,代码行数:27,代码来源:bch.go
示例9: TestCommandYamlFileTestGlobalEnvVarWinsNested
func TestCommandYamlFileTestGlobalEnvVarWinsNested(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
ioutil.WriteFile("current.yaml", []byte(`top:
test: 15`), 0666)
defer os.Remove("current.yaml")
os.Setenv("THE_TEST", "10")
defer os.Setenv("THE_TEST", "")
test := []string{"test-cmd", "--load", "current.yaml"}
set.Parse(test)
c := cli.NewContext(app, set, nil)
command := &cli.Command{
Name: "test-cmd",
Aliases: []string{"tc"},
Usage: "this is for testing",
Description: "testing",
Action: func(c *cli.Context) error {
val := c.Int("top.test")
expect(t, val, 10)
return nil
},
Flags: []cli.Flag{
NewIntFlag(cli.IntFlag{Name: "top.test", EnvVar: "THE_TEST"}),
cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
err := command.Run(c)
expect(t, err, nil)
}
开发者ID:CowLeo,项目名称:cli,代码行数:34,代码来源:yaml_command_test.go
示例10: main
func main() {
app := cli.NewApp()
app.Name = "space"
app.Usage = "A user management microservice; OAuth 2 provider"
app.EnableBashCompletion = true
app.Commands = []cli.Command{
{
Name: "serve",
Aliases: []string{"s"},
Usage: "Serve the application server",
Action: func(c *cli.Context) error {
tasks.Server()
return nil
},
},
{
Name: "client",
Aliases: []string{"c"},
Usage: "Manage client application",
Subcommands: []cli.Command{
{
Name: "create",
Usage: "Create a new client application",
Action: func(c *cli.Context) error {
tasks.CreateClient()
return nil
},
},
},
},
}
app.Run(os.Args)
}
开发者ID:earaujoassis,项目名称:space,代码行数:34,代码来源:main.go
示例11: NewApp
func NewApp(baseName string, cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) {
cli.AppHelpTemplate = appHelpTemplate()
cli.CommandHelpTemplate = commandHelpTemplate()
app = cli.NewApp()
app.Name = appConfig.Name
app.HelpName = appConfig.HelpName
app.Usage = appConfig.Usage
app.Version = appConfig.Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "skipSslChecks",
Usage: "Skip verification of server's certificate chain and hostname (for use with self-signed certs)",
},
}
app.Commands = []cli.Command{}
for _, metadata := range metadatas {
primaryCommand := getCommand(baseName, metadata, cmdRunner)
app.Commands = append(app.Commands, primaryCommand)
}
return
}
开发者ID:johnmccabe,项目名称:brooklyn-client,代码行数:25,代码来源:app.go
示例12: NewApp
func NewApp(baseName string, cmdRunner command_runner.Runner, metadatas ...command_metadata.CommandMetadata) (app *cli.App) {
cli.AppHelpTemplate = appHelpTemplate()
cli.CommandHelpTemplate = commandHelpTemplate()
app = cli.NewApp()
app.Name = appConfig.Name
app.HelpName = appConfig.HelpName
app.Usage = appConfig.Usage
app.Version = appConfig.Version
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "skipSslChecks",
Usage: "Skip verification of server's certificate chain and hostname (for use with self-signed certs)",
},
cli.StringFlag{
Name: "json, j",
Usage: "Render value as json with json path selector as described at https://github.com/NodePrime/jsonpath. (Experimental, not supported on all commands at present) ",
},
}
app.Commands = []cli.Command{}
for _, metadata := range metadatas {
primaryCommand := getCommand(baseName, metadata, cmdRunner)
app.Commands = append(app.Commands, primaryCommand)
}
return
}
开发者ID:m4rkmckenna,项目名称:brooklyn-client,代码行数:29,代码来源:app.go
示例13: main
func main() {
app := cli.NewApp()
app.Name = "cli"
app.Usage = "cli [command] [args...]"
app.Commands = []cli.Command{
{
Name: "server",
Usage: "Run the MerkleEyes server",
Flags: []cli.Flag{
cli.StringFlag{
Name: "address",
Value: "unix://data.sock",
Usage: "MerkleEyes server listen address",
},
cli.StringFlag{
Name: "tmsp",
Value: "socket",
Usage: "socket | grpc",
},
},
Action: func(c *cli.Context) {
cmdServer(app, c)
},
},
}
app.Run(os.Args)
}
开发者ID:tendermint,项目名称:merkleeyes,代码行数:28,代码来源:merkleeyes.go
示例14: main
func main() {
app := cli.NewApp()
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "docker, d",
Value: "unix:///var/run/docker.sock",
Usage: "Docker address",
},
cli.StringFlag{
Name: "label-filter, f",
Value: "router=fusis",
Usage: "Label to lookup when listing docker containers",
},
cli.DurationFlag{
Name: "interval, i",
Value: time.Minute,
Usage: "Interval between calls docker listing containers.\n" +
"Docker events will also be used, pooling interval is a failsafe mechanism for missed events",
},
cli.StringFlag{
Name: "fusis-addr, a",
Value: "",
Usage: "Address of the fusis router",
},
}
app.Version = "0.1.0"
app.Name = "fusis-agent"
app.Action = runAgent
app.Author = "fusis team"
app.Email = "https://github.com/luizbafilho/fusis"
app.Run(os.Args)
}
开发者ID:cezarsa,项目名称:fusis-agent,代码行数:32,代码来源:main.go
示例15: main
func main() {
app := cli.NewApp()
app.Name = "oci-runtime-tool"
app.Version = "0.0.1"
app.Usage = "OCI (Open Container Initiative) runtime tools"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "log-level",
Value: "error",
Usage: "Log level (panic, fatal, error, warn, info, or debug)",
},
cli.BoolFlag{
Name: "host-specific",
Usage: "generate host-specific configs or do host-specific validations",
},
}
app.Commands = []cli.Command{
generateCommand,
bundleValidateCommand,
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}
开发者ID:wking,项目名称:ocitools-v2,代码行数:26,代码来源:main.go
示例16: main
func main() {
app := cli.NewApp()
app.Name = "bulletin"
app.Version = "0.0.1"
app.Usage = "Service for exposing dynamic information from other services for collection and parsing"
app.Action = setup
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "host, H",
Value: "::",
Usage: "Bind to `HOST`",
},
cli.IntFlag{
Name: "port, P",
Value: 2626,
Usage: "Bind to `PORT`",
},
cli.StringFlag{
Name: "dir, d",
Value: "/var/lib/bulletin",
Usage: "Load data from `DIR`",
},
cli.BoolFlag{
Name: "debug",
Usage: "Print debug information",
},
}
app.Run(os.Args)
}
开发者ID:akerl,项目名称:bulletin,代码行数:32,代码来源:main.go
示例17: main
func main() {
app := cli.NewApp()
app.Name = "coverage generator"
app.Usage = "generate and publish coverage reports"
app.Version = version
app.Before = setup
app.Flags = []cli.Flag{
cli.BoolFlag{
Name: "ci",
Usage: "continuous integration mode",
EnvVar: "CI",
},
cli.BoolTFlag{
Name: "debug",
Usage: "debug mode",
EnvVar: "DEBUG",
},
}
app.Commands = []cli.Command{
LcovCmd,
GocovCmd,
PublishCmd,
}
app.Run(os.Args)
}
开发者ID:drone-plugins,项目名称:drone-coverage,代码行数:26,代码来源:main.go
示例18: TestCommandTomlFileTestDefaultValueFileWinsNested
func TestCommandTomlFileTestDefaultValueFileWinsNested(t *testing.T) {
app := cli.NewApp()
set := flag.NewFlagSet("test", 0)
ioutil.WriteFile("current.toml", []byte("[top]\ntest = 15"), 0666)
defer os.Remove("current.toml")
test := []string{"test-cmd", "--load", "current.toml"}
set.Parse(test)
c := cli.NewContext(app, set, nil)
command := &cli.Command{
Name: "test-cmd",
Aliases: []string{"tc"},
Usage: "this is for testing",
Description: "testing",
Action: func(c *cli.Context) error {
val := c.Int("top.test")
expect(t, val, 15)
return nil
},
Flags: []cli.Flag{
NewIntFlag(cli.IntFlag{Name: "top.test", Value: 7}),
cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))
err := command.Run(c)
expect(t, err, nil)
}
开发者ID:otsimo,项目名称:catalog,代码行数:31,代码来源:toml_command_test.go
示例19: init
func init() {
// Initialise a CLI app
cliApp = cli.NewApp()
cliApp.Name = "Example API CLI"
cliApp.Usage = "example-api"
cliApp.Version = "0.0.0"
}
开发者ID:RichardKnop,项目名称:example-api,代码行数:7,代码来源:main.go
示例20: Run
// Run the CLI
func Run() {
cli.VersionPrinter = printVersion
app := cli.NewApp()
app.Name = path.Base(os.Args[0])
app.Usage = "bitrise-machine"
app.Version = "0.9.10"
app.Author = ""
app.Email = ""
app.Before = before
app.Flags = appFlags
app.Commands = commands
if cpuProfileFilePath := os.Getenv(CPUProfileFilePathEnvKey); cpuProfileFilePath != "" {
log.Infof("Enabling CPU Profiler, writing results into file: %s", cpuProfileFilePath)
f, err := os.Create(cpuProfileFilePath)
if err != nil {
log.Fatalf("CPU Profile: failed to create file: %s", err)
}
if err := pprof.StartCPUProfile(f); err != nil {
log.Fatalf("CPU Profile: failed to start CPU profiler: %s", err)
}
defer pprof.StopCPUProfile()
}
if err := app.Run(os.Args); err != nil {
log.Fatal("Finished with error:", err)
}
}
开发者ID:bitrise-tools,项目名称:bitrise-machine,代码行数:33,代码来源:cli.go
注:本文中的github.com/urfave/cli.NewApp函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论