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


Golang cli.NewApp函数代码示例

本文整理汇总了Golang中github.com/urfave/cli.NewApp函数的典型用法代码示例。如果您正苦于以下问题:Golang NewApp函数的具体用法?Golang NewApp怎么用?Golang NewApp使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewApp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


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