• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang cli.NewApp函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Test_glob_opts

func Test_glob_opts(t *testing.T) {
	{
		app := cli.NewApp()
		var our_wc watch.Config
		app.Flags = global_flags(&our_wc)
		is := make_is(t)
		app.Run([]string{""})
		is(our_wc.Debug, false, "debug off")
		is(our_wc.ProcessExistingFiles, false, "process existing off")
		is(our_wc.ReportErrors, true, "Error reportin on by default")
		is(our_wc.ReportActions, false, "Action reporting on by default")
		if our_wc.Paranoia != watch.NoParanoia {
			t.Fatal("unexpected paranoia")
		}
	}
	{
		app := cli.NewApp()
		var our_wc watch.Config
		app.Flags = global_flags(&our_wc)
		is := make_is(t)
		app.Run([]string{"", "--archive=FISHBOWL", "--error-dir=CATBASKET", "--debug", "--log-actions", "--log-errors=false", "--process-existing"})
		is(our_wc.ArchiveDir, "FISHBOWL", "archive dir")
		is(our_wc.ErrorDir, "CATBASKET", "error dir")
		is(our_wc.Debug, true, "debug on")
		is(our_wc.ReportActions, true, "action reporting on")
		is(our_wc.ReportErrors, false, "error reporting off")
		is(our_wc.ProcessExistingFiles, true, "process existing on")
	}
}
开发者ID:draxil,项目名称:springboard,代码行数:29,代码来源:springboard_test.go


示例2: Run

func (cmd *Command) Run(args []string) error {
	url, args, err := findVulcanUrl(args)
	if err != nil {
		return err
	}
	cmd.vulcanUrl = url
	cmd.client = api.NewClient(cmd.vulcanUrl, cmd.registry)

	app := cli.NewApp()
	app.Name = "vctl"
	app.Usage = "Command line interface to a running vulcan instance"
	app.Flags = flags()

	app.Commands = []cli.Command{
		NewLogCommand(cmd),
		NewKeyCommand(cmd),
		NewTopCommand(cmd),
		NewHostCommand(cmd),
		NewBackendCommand(cmd),
		NewFrontendCommand(cmd),
		NewServerCommand(cmd),
		NewListenerCommand(cmd),
	}
	app.Commands = append(app.Commands, NewMiddlewareCommands(cmd)...)
	return app.Run(args)
}
开发者ID:vnadgir-ef,项目名称:vulcand,代码行数:26,代码来源:command.go


示例3: main

func main() {
	factory := &dockerApp.ProjectFactory{}

	app := cli.NewApp()
	app.Name = "libcompose-cli"
	app.Usage = "Command line interface for libcompose."
	app.Version = version.VERSION + " (" + version.GITCOMMIT + ")"
	app.Author = "Docker Compose Contributors"
	app.Email = "https://github.com/docker/libcompose"
	app.Before = cliApp.BeforeApp
	app.Flags = append(command.CommonFlags(), dockerApp.DockerClientFlags()...)
	app.Commands = []cli.Command{
		command.BuildCommand(factory),
		command.CreateCommand(factory),
		command.DownCommand(factory),
		command.KillCommand(factory),
		command.LogsCommand(factory),
		command.PauseCommand(factory),
		command.PortCommand(factory),
		command.PsCommand(factory),
		command.PullCommand(factory),
		command.RestartCommand(factory),
		command.RmCommand(factory),
		command.RunCommand(factory),
		command.ScaleCommand(factory),
		command.StartCommand(factory),
		command.StopCommand(factory),
		command.UnpauseCommand(factory),
		command.UpCommand(factory),
	}

	app.Run(os.Args)

}
开发者ID:kunalkushwaha,项目名称:libcompose,代码行数:34,代码来源:main.go


示例4: main

func main() {
	app := cli.NewApp()
	app.Name = "speedland-agent"
	app.Usage = "A agent command for speedland.net"
	app.Version = "1.0.0"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			"config, c",
			"wcg.ini",
			"configuration file",
			"WCG_INI_FILE",
		},
	}
	app.Before = func(c *cli.Context) error {
		wcg.ConfigureProcess(c.String("config"))
		// normalize path
		lib.Config.Endpoint.Path = ""
		wcg.NewLogger(nil).Info("Used configurn file: %q", c.String("config"))
		wcg.NewLogger(nil).Info("Target Endpoint: %q", lib.Config.Endpoint)
		wcg.NewLogger(nil).Debug("Token: %q", lib.Config.Token)
		return nil
	}
	app.Commands = commands.AllCommands()
	app.Run(os.Args)
	wcg.WaitLogs()
}
开发者ID:speedland,项目名称:apps,代码行数:26,代码来源:main.go


示例5: main

func main() {
	//p, _ := os.Create("twobit.cpuprofile")
	//pprof.StartCPUProfile(p)
	//defer pprof.StopCPUProfile()
	app := cli.NewApp()
	app.Name = "twobit"
	app.Authors = []cli.Author{cli.Author{Name: "Andrew E. Bruno", Email: "[email protected]"}}
	app.Usage = "Read/Write .2bit files"
	app.Version = "0.0.1"
	app.Commands = []cli.Command{
		{
			Name:  "convert",
			Usage: "Convert FASTA file to .2bit format.",
			Flags: []cli.Flag{
				&cli.BoolFlag{Name: "to-fasta, f", Usage: "Convert .2bit file to FASTA"},
				&cli.StringFlag{Name: "in, i", Usage: "Input file"},
				&cli.StringFlag{Name: "out, o", Usage: "Output file"},
			},
			Action: func(c *cli.Context) {
				if c.Bool("to-fasta") {
					ToFasta(c.String("in"), c.String("out"))
					return
				}

				To2bit(c.String("in"), c.String("out"))
			},
		},
	}

	app.Run(os.Args)
}
开发者ID:wingolab,项目名称:twobit,代码行数:31,代码来源:main.go


示例6: TestResizeHandleSingle

func TestResizeHandleSingle(t *testing.T) {
	th.SetupHTTP()
	defer th.TeardownHTTP()
	th.Mux.HandleFunc("/servers/detail", func(w http.ResponseWriter, r *http.Request) {
		w.Header().Add("Content-Type", "application/json")
		fmt.Fprintf(w, `{"servers":[{"ID":"server1","Name":"server1Name"}]}`)
	})
	app := cli.NewApp()
	flagset := flag.NewFlagSet("flags", 1)
	flagset.String("id", "", "")
	flagset.Set("id", "server1")
	c := cli.NewContext(app, flagset, nil)
	cmd := &commandResize{
		Ctx: &handler.Context{
			CLIContext:    c,
			ServiceClient: client.ServiceClient(),
		},
	}
	expected := &handler.Resource{
		Params: &paramsResize{
			serverID: "server1",
		},
	}
	actual := &handler.Resource{
		Params: &paramsResize{},
	}
	err := cmd.HandleSingle(actual)
	th.AssertNoErr(t, err)
	th.AssertEquals(t, expected.Params.(*paramsResize).serverID, actual.Params.(*paramsResize).serverID)
}
开发者ID:flazz,项目名称:rack,代码行数:30,代码来源:resize_test.go


示例7: main

func main() {
	log := logrus.New()
	cli.VersionPrinter = func(c *cli.Context) {
		fmt.Printf("%s v=%s d=%s\n", c.App.Name, c.App.Version, GeneratedString)
	}

	app := cli.NewApp()
	app.Name = "artifacts-service"
	app.Version = VersionString
	app.Commands = []cli.Command{
		{
			Name:      "serve",
			ShortName: "s",
			Usage:     "run the HTTP thing",
			Action: func(_ *cli.Context) {
				server.Main(log)
			},
		},
		{
			Name:      "migrate",
			ShortName: "m",
			Usage:     "run database migrations",
			Action: func(_ *cli.Context) {
				server.MigratorMain(log)
			},
		},
	}

	app.Run(os.Args)
}
开发者ID:hamfist,项目名称:artifacts-service,代码行数:30,代码来源:artifacts_service.go


示例8: NewApp

func NewApp() *cli.App {
	app := cli.NewApp()
	app.Name = "flint"
	app.Usage = "Check a project for common sources of contributor friction"
	app.Version = "0.0.4"
	app.Flags = []cli.Flag{
		cli.BoolFlag{"skip-readme", "skip check for README", ""},
		cli.BoolFlag{"skip-contributing", "skip check for contributing guide", ""},
		cli.BoolFlag{"skip-license", "skip check for license", ""},
		cli.BoolFlag{"skip-bootstrap", "skip check for bootstrap script", ""},
		cli.BoolFlag{"skip-test-script", "skip check for test script", ""},
		cli.BoolFlag{"skip-scripts", "skip check for all scripts", ""},
		cli.BoolFlag{"no-color", "skip coloring the terminal output", ""},
		cli.StringFlag{
			Name:  "github, g",
			Value: "",
			Usage: "GitHub repository as owner/repo",
		},
		cli.StringFlag{
			Name:   "token, t",
			Value:  "",
			EnvVar: "FLINT_TOKEN",
			Usage:  "GitHub API access token",
		},
	}
	app.Action = func(c *cli.Context) {
		run(c)
	}

	return app
}
开发者ID:pkdevbox,项目名称:flint,代码行数:31,代码来源:app.go


示例9: main

func main() {
	app := cli.NewApp()
	app.Name = "initUpdater"
	app.Usage = "initUpdater is to init user table."
	app.Action = func(c *cli.Context) {
		/* -- DB -- */
		db, err := sql.Open("mysql", "root:@/test_bbs")
		if err != nil {
			panic(err.Error())
		}
		defer db.Close()

		/* -- SQL -- */
		sql_1 := "UPDATE user SET name = 'Paul', modified = NOW() WHERE id = 1;"
		data1, _ := db.Exec(sql_1)

		sql_2 := "UPDATE user SET name = 'John', modified = NOW() WHERE id = 2;"
		data2, _ := db.Exec(sql_2)

		println(data1)
		println(data2)
		println("initUdpater Finished!")
	}

	app.Run(os.Args)
}
开发者ID:hayatravis,项目名称:goji_bbs_sample,代码行数:26,代码来源:init_updater.go


示例10: main

func main() {
	app := cli.NewApp()
	app.Name = "nbad"
	app.Usage = "NSCA Buffering Agent (daemon) - Emulates NSCA interface as local buffer/proxy"

	var configFile string
	var trace bool

	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:        "config, c",
			Value:       defaultConfLocation,
			Usage:       "Location of config file on disk",
			Destination: &configFile,
		},
		cli.BoolFlag{
			Name:        "trace, t",
			EnvVar:      "NBAD_TRACE",
			Usage:       "Turn on trace-logging",
			Destination: &trace,
		},
	}
	app.Version = "1.0"
	app.Action = func(c *cli.Context) {
		// load configuration
		InitConfig(configFile, TempLogger("STARTUP"))
		Config().TraceLogging = trace

		startServer()
	}
	app.Run(os.Args)
}
开发者ID:JohnMurray,项目名称:nbad,代码行数:32,代码来源:main.go


示例11: main

func main() {
	app := cli.NewApp()
	app.Version = ""
	app.Usage = "Mount and manage Ceph RBD for containers"
	app.Flags = []cli.Flag{
		cli.BoolFlag{
			Name:   "debug",
			Usage:  "Turn on debug logging",
			EnvVar: "DEBUG",
		},
		cli.StringFlag{
			Name:   "master",
			Usage:  "Set the volmaster host:port",
			EnvVar: "MASTER",
			Value:  "localhost:8080",
		},
		cli.StringFlag{
			Name:   "host-label",
			Usage:  "Set the internal hostname",
			EnvVar: "HOSTLABEL",
			Value:  host,
		},
	}
	app.Action = run

	app.Run(os.Args)
}
开发者ID:hankerepo,项目名称:volplugin,代码行数:27,代码来源:cli.go


示例12: Init

func Init() {
	cli.AppHelpTemplate = `
GLOBAL OPTIONS:
   {{range .Flags}}{{.}}
   {{end}}
`

	cli.HelpPrinter = func(writer io.Writer, templ string, data interface{}) {
		w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
		t := template.Must(template.New("help").Parse(templ))
		err := t.Execute(w, data)
		if err != nil {
			panic(err)
		}
		w.Flush()
		os.Exit(2)
	}

	app := cli.NewApp()
	app.HideVersion = true
	app.Usage = "a go micro app"
	app.Action = func(c *cli.Context) {}
	app.Before = Setup
	app.Flags = Flags
	app.RunAndExitOnError()
}
开发者ID:kgrvamsi,项目名称:go-micro,代码行数:26,代码来源:cmd.go


示例13: TestListHandleFlags

func TestListHandleFlags(t *testing.T) {
	app := cli.NewApp()
	flagset := flag.NewFlagSet("flags", 1)
	flagset.String("image", "", "")
	flagset.String("flavor", "", "")
	flagset.String("name", "", "")
	flagset.String("status", "", "")
	flagset.String("marker", "", "")
	flagset.Set("image", "13ba-75c0-4483-acf9")
	flagset.Set("flavor", "1234-b95f-ac5b-cd23")
	flagset.Set("name", "server*")
	flagset.Set("status", "AVAILABLE")
	flagset.Set("marker", "1fd3-4f9f-44df-1b5c")
	c := cli.NewContext(app, flagset, nil)
	cmd := &commandList{
		Ctx: &handler.Context{
			CLIContext: c,
		},
	}
	expected := &handler.Resource{
		Params: &paramsList{
			opts: &osServers.ListOpts{
				Image:  "13ba-75c0-4483-acf9",
				Flavor: "1234-b95f-ac5b-cd23",
				Name:   "server*",
				Status: "AVAILABLE",
				Marker: "1fd3-4f9f-44df-1b5c",
			},
		},
	}
	actual := &handler.Resource{}
	err := cmd.HandleFlags(actual)
	th.AssertNoErr(t, err)
	th.AssertDeepEquals(t, *expected.Params.(*paramsList).opts, *actual.Params.(*paramsList).opts)
}
开发者ID:flazz,项目名称:rack,代码行数:35,代码来源:list_test.go


示例14: main

func main() {
	// Add a check to see if gitversion is blank from the build process
	if gitversion == "" {
		gitversion = "unknown"
	}

	app := cli.NewApp()
	app.Name = "snapd"
	app.Version = gitversion
	app.Usage = "A powerful telemetry framework"
	app.Flags = []cli.Flag{
		flAPIDisabled,
		flAPIPort,
		flAPIAddr,
		flLogLevel,
		flLogPath,
		flMaxProcs,
		flAutoDiscover,
		flNumberOfPLs,
		flCache,
		flPluginTrust,
		flKeyringPaths,
		flRestCert,
		flConfig,
		flRestHTTPS,
		flRestKey,
		flRestAuth,
	}
	app.Flags = append(app.Flags, scheduler.Flags...)
	app.Flags = append(app.Flags, tribe.Flags...)

	app.Action = action
	app.Run(os.Args)
}
开发者ID:jcooklin,项目名称:snap,代码行数:34,代码来源:snapd.go


示例15: main

func main() {
	app := cli.NewApp()
	app.Name = "seaweed-cli"
	app.Usage = "Should I go surfing?"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "apiKey",
			Usage:  "Magic Seaweed API key",
			EnvVar: "MAGIC_SEAWEED_API_KEY",
		},
	}
	app.Commands = []cli.Command{
		{
			Name:        "forecast",
			Usage:       "forcast <spotId>",
			Description: "View the forecast for a spot",
			Action:      forecast,
		},
		{
			Name:        "today",
			Usage:       "today <spotId>",
			Description: "View today's forecast for a spot",
			Action:      today,
		},
		{
			Name:        "tomorrow",
			Usage:       "tomorrow <spotId>",
			Description: "View tomorrow's forecast for a spot",
			Action:      tomorrow,
		},
	}
	app.Run(os.Args)
}
开发者ID:TomDeVito,项目名称:seaweed-cli,代码行数:33,代码来源:seaweed.go


示例16: ExampleAppHelp

func ExampleAppHelp() {
	// set args for examples sake
	os.Args = []string{"greet", "h", "describeit"}

	app := cli.NewApp()
	app.Name = "greet"
	app.Flags = []cli.Flag{
		cli.StringFlag{Name: "name", Value: "bob", Usage: "a name to say"},
	}
	app.Commands = []cli.Command{
		{
			Name:        "describeit",
			Aliases:     []string{"d"},
			Usage:       "use it to see a description",
			Description: "This is how we describe describeit the function",
			Action: func(c *cli.Context) {
				fmt.Printf("i like to describe things")
			},
		},
	}
	app.Run(os.Args)
	// Output:
	// NAME:
	//    describeit - use it to see a description
	//
	// USAGE:
	//    command describeit [arguments...]
	//
	// DESCRIPTION:
	//    This is how we describe describeit the function
}
开发者ID:CedarLogic,项目名称:go-ethereum,代码行数:31,代码来源:app_test.go


示例17: withinTest

func withinTest(cs Config, fs *flag.FlagSet, fn func(*cli.Context)) {
	ogSource := DefaultConfig
	DefaultConfig = cs

	defer func() {
		DefaultConfig = ogSource
	}()

	var b bytes.Buffer
	app := cli.NewApp()
	app.Writer = bufio.NewWriter(&b)

	globalSet := flag.NewFlagSet("global test", 0)
	globalSet.String("token", "token", "token")

	globalCtx := cli.NewContext(app, globalSet, nil)

	if fs == nil {
		fs = flag.NewFlagSet("local test", 0)
	}

	c := cli.NewContext(app, fs, globalCtx)

	fn(c)
}
开发者ID:mattkanwisher,项目名称:doit,代码行数:25,代码来源:util.go


示例18: main

func main() {
	app := cli.NewApp()
	app.Name = "speedland-ng-agent: intern/pt"
	app.Version = lib.Commit
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:   "config, c",
			Value:  "wcg.ini",
			Usage:  "configuration file",
			EnvVar: "WCG_INI_FILE",
		},
	}
	app.Before = func(c *cli.Context) error {
		agent.InitLog(c.String("config"))
		return nil
	}
	app.Action = func(c *cli.Context) {
		agent.RunAgent(
			async.NewRegularIntervalAgent(
				pt.NewAgent(agent.DefaultConfig.Endpoint.String(), agent.DefaultConfig.Token, nil),
				60*time.Second,
			),
		)
		wcg.WaitLogs()
	}
	app.Run(os.Args)
}
开发者ID:speedland,项目名称:service,代码行数:27,代码来源:main.go


示例19: main

func main() {
	app := cli.NewApp()
	app.Name = "qunosy"           // ヘルプを表示する際に使用される
	app.Usage = "print arguments" // ヘルプを表示する際に使用される
	app.Version = "0.1.0"         // ヘルプを表示する際に使用される
	absPath, _ := filepath.Abs("../qunosy")
	app.Action = func(c *cli.Context) { // コマンド実行時の処理
		if len(c.Args()) > 1 {
			if c.Args()[0] == "reload" {
				fmt.Println("Reloading qiita log ...")
				reload := exec.Command("sh", absPath+"/reload.sh", c.Args()[1])
				reloadOut, err := reload.Output()
				if err != nil {
					fmt.Println(err.Error())
					return
				}
				fmt.Print(string(reloadOut))
			} else {
				return
			}
		} else {
			qunosy := exec.Command("sh", absPath+"/qunosy.sh")
			qunosyOut, err := qunosy.Output()
			if err != nil {
				fmt.Println(err.Error())
				return
			}
			fmt.Print(string(qunosyOut))
		}
	}
	app.Run(os.Args)
}
开发者ID:falsandtru,项目名称:qunosy,代码行数:32,代码来源:qunosy.go


示例20: Run

// Run the Envman CLI.
func Run() {
	// Read piped data
	if isPipedData() {
		if bytes, err := ioutil.ReadAll(os.Stdin); err != nil {
			log.Error("[ENVMAN] - Failed to read stdin:", err)
		} else if len(bytes) > 0 {
			stdinValue = string(bytes)
		}
	}

	// Parse cl
	cli.VersionPrinter = printVersion

	app := cli.NewApp()
	app.Name = path.Base(os.Args[0])
	app.Usage = "Environment variable manager"
	app.Version = "1.1.0"

	app.Author = ""
	app.Email = ""

	app.Before = before

	app.Flags = flags
	app.Commands = commands

	if err := app.Run(os.Args); err != nil {
		log.Fatal("[ENVMAN] - Finished:", err)
	}
}
开发者ID:fbernardo,项目名称:envman,代码行数:31,代码来源:cli.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang cli.NewContext函数代码示例发布时间:2022-05-23
下一篇:
Golang types.Store类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap