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


Golang cli.ShowAppHelp函数代码示例

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


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

示例1: Action

func Action(c *cli.Context) {
	if len(c.Args()) < 1 {
		fmt.Println("ERROR: Please specify a a task\n\n")
		cli.ShowAppHelp(c)
		return
	}

	task := c.Args()[0]

	tplVars := c.GlobalString("vars")
	cfgPath := c.GlobalString("config")
	env := c.GlobalString("environment")
	host := c.GlobalString("host")

	vars := parseVars(tplVars)
	file, err := ioutil.ReadFile(cfgPath)
	if err != nil {
		fmt.Printf("ERROR: could not find the config file: %s\n\n", cfgPath)
		cli.ShowAppHelp(c)
		return
	}

	cfg := LoadConfig(file, vars, env)
	if host != "" {
		Run(task, []string{host}, cfg)
	} else {
		Run(task, cfg.DeployEnvs[env].Hosts, cfg)
	}
}
开发者ID:ebenoist,项目名称:ply,代码行数:29,代码来源:main.go

示例2: GetCmd

// GetCmd extracts cmd from command line
func GetCmd(c *cli.Context) (cmd string) {
	argc := len(c.Args())
	if argc >= 2 {
		if cl.fifoFile == "" || argc > 2 {
			fmt.Println("Too Many Arguments (Command Must Be the Last One Parameter) !")
			cli.ShowAppHelp(c)
			os.Exit(1)
		}
	loop:
		for _, arg := range c.Args() {
			if arg != cl.fifoFile {
				cmd = arg
				break loop
			}
		}
	} else if argc == 1 && c.Args()[0] == cl.fifoFile || argc == 0 {
		cmd = getPipe(PIPEUSEDBYCMD)
		return
		fmt.Println("Command Must Be the Last One Parameter!")
		cli.ShowAppHelp(c)
		os.Exit(1)
	} else {
		cmd = c.Args()[argc-1]
	}
	return
}
开发者ID:hkhkhk1987,项目名称:gsck,代码行数:27,代码来源:commander.go

示例3: runApp

func runApp(c *cli.Context) {
	uri := "amqp://guest:[email protected]" + c.String("server") + ":5672"

	queueName := queueBaseName
	queueDurability := c.Bool("durable")

	if c.String("queuesuffix") != "" {
		queueName = fmt.Sprintf("%s-%s", queueBaseName, c.String("queuesuffix"))
	}

	if c.Int("consumer") > -1 && c.Int("producer") != 0 {
		fmt.Println("Error: Cannot specify both producer and consumer options together")
		fmt.Println()
		cli.ShowAppHelp(c)
		os.Exit(1)
	} else if c.Int("consumer") > -1 {
		fmt.Println("Running in consumer mode")
		config := ConsumerConfig{uri, c.Bool("quiet")}
		makeConsumers(config, queueName, queueDurability, c.Int("concurrency"), c.Int("consumer"))
	} else if c.Int("producer") != 0 {
		fmt.Println("Running in producer mode")
		config := ProducerConfig{uri, c.Bool("quiet"), c.Int("bytes"), c.Bool("wait-for-ack")}
		makeProducers(config, queueName, queueDurability, c.Int("concurrency"), c.Int("producer"), c.Int("wait"))
	} else {
		cli.ShowAppHelp(c)
		os.Exit(0)
	}
}
开发者ID:MartyMacGyver,项目名称:rabbit-mq-stress-tester,代码行数:28,代码来源:tester.go

示例4: run

func run(c *cli.Context) {

	user := c.String("User")
	if 0 == len(user) {
		cli.ShowAppHelp(c)
		log.Fatal("User must be provided")
	}

	text := c.String("Text")
	if 0 == len(text) {
		cli.ShowAppHelp(c)
		log.Fatal("Text must be provided")
	}

	amqpUri := c.String("AmqpUri")
	amqpExchange := c.String("AmqpExchange")
	amqpType := "direct"
	key := c.String("AmqpKey")
	amqpService := xmpptoamqp.NewAmqpService(&amqpUri, nil, nil, nil)
	amqpService.ExchangeDeclare(&amqpExchange, &amqpType)
	amqpService.Send(&amqpExchange, &key, &user, &text)

	log.WithFields(log.Fields{
		"user": c.String("User"),
	}).Info("Chat sent")

}
开发者ID:russellchadwick,项目名称:xmpptoamqp,代码行数:27,代码来源:send.go

示例5: main

func main() {
	cli.AppHelpTemplate = AppHelpTemplate
	cli.CommandHelpTemplate = CommandHelpTemplate
	cli.SubcommandHelpTemplate = SubcommandHelpTemplate
	cli.VersionPrinter = printVersion

	app := cli.NewApp()
	app.Name = "buildkite-agent"
	app.Version = agent.Version()
	app.Commands = []cli.Command{
		clicommand.AgentStartCommand,
		{
			Name:  "artifact",
			Usage: "Upload/download artifacts from Buildkite jobs",
			Subcommands: []cli.Command{
				clicommand.ArtifactUploadCommand,
				clicommand.ArtifactDownloadCommand,
				clicommand.ArtifactShasumCommand,
			},
		},
		{
			Name:  "meta-data",
			Usage: "Get/set data from Buildkite jobs",
			Subcommands: []cli.Command{
				clicommand.MetaDataSetCommand,
				clicommand.MetaDataGetCommand,
				clicommand.MetaDataExistsCommand,
			},
		},
		{
			Name:  "pipeline",
			Usage: "Make changes to the pipeline of the currently running build",
			Subcommands: []cli.Command{
				clicommand.PipelineUploadCommand,
			},
		},
		clicommand.BootstrapCommand,
	}

	// When no sub command is used
	app.Action = func(c *cli.Context) {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}

	// When a sub command can't be found
	app.CommandNotFound = func(c *cli.Context, command string) {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}

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

示例6: common

func common(c *cli.Context) error {
	if c.GlobalString("seed") == "" {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}
	if c.GlobalInt("sequence") == 0 {
		cli.ShowAppHelp(c)
		os.Exit(1)
	}
	key = parseSeed(c.String("seed"))
	return nil
}
开发者ID:Zoramite,项目名称:ripple,代码行数:12,代码来源:tx.go

示例7: ServiceMaint

func ServiceMaint(c *cli.Context) {
	// Get client
	cfg, err := NewAppConfig(c)
	if err != nil {
		log.Errorf("Failed to get client: %v", err)
		return
	}
	action := c.Args().First()
	service := c.Args().Tail()[0]
	reason := ""

	if len(c.Args().Tail()) > 1 {
		reason = c.Args().Tail()[1]
	}

	switch action {
	case "enable":
		if err = cfg.client.Agent().EnableServiceMaintenance(service, reason); err != nil {
			log.Errorf("Error setting maintenance mode: %v", err)
			return
		}
	case "disable":
		if err = cfg.client.Agent().DisableServiceMaintenance(service); err != nil {
			log.Errorf("Error disabling maintenance mode: %v", err)
			return
		}
	default:
		cli.ShowAppHelp(c)
		return
	}

	log.Println("Success")
}
开发者ID:colebrumley,项目名称:consulctl,代码行数:33,代码来源:services.go

示例8: NewApp

func NewApp() *cli.App {
	cmds, err := parseCommands()
	if err != nil {
		log.Fatal(err)
	}

	app := cli.NewApp()
	app.Name = "gotask"
	app.Usage = "Build tool in Go"
	app.Version = Version
	app.Commands = cmds
	app.Flags = []cli.Flag{
		compileFlag{Usage: "compile the task binary to pkg.task but do not run it"},
	}
	app.Action = func(c *cli.Context) {
		if c.Bool("c") || c.Bool("compile") {
			err := compileTasks()
			if err != nil {
				log.Fatal(err)
			}

			return
		}

		if len(c.Args()) == 0 {
			cli.ShowAppHelp(c)
		}
	}

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

示例9: GenerateDoc

// GenerateDoc generating new documentation
func GenerateDoc(c *cli.Context) {
	md := c.String("input")
	html := c.String("output")
	t := c.String("template")
	path := c.String("path")
	sidebar := c.String("sidebar")

	if md == "" {
		cli.ShowAppHelp(c)
		return
	}

	fmt.Println("Begin generate")
	sb, _ := NewSidebar(sidebar)
	parent := &Dir{sidebar: sb}

	dir, err := NewDir(md, html, t, path)
	if err != nil {
		fmt.Printf("Error read dir %s\n \t%s\n", dir.mdDir, err.Error())
	}
	err = dir.read()

	if err != nil {
		fmt.Printf("Error read dir %s\n \t%s\n", dir.mdDir, err.Error())
	}
	err = dir.write(parent)

	if err != nil {
		fmt.Printf("Error write dir %s\n", dir.htmlDir)
	}

	fmt.Println("End generate")
}
开发者ID:cnam,项目名称:md2html,代码行数:34,代码来源:generator.go

示例10: ToggleMaintenanceMode

func ToggleMaintenanceMode(c *cli.Context) {
	cfg, err := NewAppConfig(c)
	if err != nil {
		log.Errorf("Failed to get client: %v", err)
		return
	}

	action := c.Args().First()

	switch action {
	case "enable":
		if err = cfg.client.Agent().EnableNodeMaintenance(c.String("reason")); err != nil {
			log.Errorf("Could not set maintenance mode: %v", err)
			return
		}
	case "disable":
		if err = cfg.client.Agent().DisableNodeMaintenance(); err != nil {
			log.Errorf("Could not unset maintenance mode: %v", err)
			return
		}
	default:
		log.Warningf("Must choose either enable or disable")
		cli.ShowAppHelp(c)
		return
	}
	log.Println("Success")
}
开发者ID:colebrumley,项目名称:consulctl,代码行数:27,代码来源:agent.go

示例11: main

func main() {
	app := cli.NewApp()
	app.Name = "seita"
	app.Usage = "Enshrine and retrieve project skeletons"
	app.EnableBashCompletion = true
	app.Authors = []cli.Author{
		{
			Name:  "Ilkka Laukkanen",
			Email: "[email protected]",
		},
	}
	app.Commands = []cli.Command{
		{
			Name:    "put",
			Aliases: []string{"p"},
			Usage:   "Offer up this project as a skeleton",
			Action:  command.Put,
		},
		{
			Name:    "make",
			Aliases: []string{"m"},
			Usage:   "Make a new project based on a skeleton",
			Action:  command.Make,
			Before:  requireArgs("get", 1),
		},
		{
			Name:    "config",
			Aliases: []string{"c"},
			Usage:   "Manipulate configuration",
			Subcommands: []cli.Command{
				{
					Name:    "set",
					Aliases: []string{"s"},
					Usage:   "Set configuration variable value",
					Action:  config.Set,
					Before:  requireArgs("set", 2),
				},
				{
					Name:    "get",
					Aliases: []string{"g"},
					Usage:   "Get configuration variable value",
					Action:  config.Get,
					Before:  requireArgs("get", 1),
				},
				{
					Name:    "list",
					Aliases: []string{"l"},
					Usage:   "List configuration variables",
					Action:  config.List,
				},
			},
		},
	}

	app.Action = func(c *cli.Context) {
		cli.ShowAppHelp(c)
	}

	app.RunAndExitOnError()
}
开发者ID:ilkka,项目名称:seita,代码行数:60,代码来源:seita.go

示例12: UpdateACL

func UpdateACL(c *cli.Context) {
	if len(c.String("id")) > 1 {
		log.Errorln("--id is required!")
		cli.ShowAppHelp(c)
		return
	}

	cfg, err := NewAppConfig(c)
	if err != nil {
		log.Errorf("Failed to get client: %v", err)
		return
	}

	_, err = cfg.client.ACL().Update(&api.ACLEntry{
		Name:  c.String("name"),
		Type:  c.String("type"),
		Rules: c.Args().First(),
		ID:    c.String("id"),
	}, cfg.writeOpts)

	if err != nil {
		log.Errorf("Could not update ACL: %v", err)
		return
	}

	fmt.Println("Success")
}
开发者ID:colebrumley,项目名称:consulctl,代码行数:27,代码来源:acl.go

示例13: getOpts

func getOpts(context *cli.Context) (string, string, string, string, string) {
	etcdURI := context.String("etcd-uri")
	redisURI := context.String("redis-uri")
	redisQueue := context.String("redis-queue")
	deployStateUri := context.String("deploy-state-uri")
	cluster := context.String("cluster")

	if etcdURI == "" || redisURI == "" || redisQueue == "" || deployStateUri == "" || cluster == "" {
		cli.ShowAppHelp(context)

		if etcdURI == "" {
			color.Red("  Missing required flag --etcd-uri or GOVERNATOR_ETCD_URI")
		}
		if redisURI == "" {
			color.Red("  Missing required flag --redis-uri or GOVERNATOR_REDIS_URI")
		}
		if redisQueue == "" {
			color.Red("  Missing required flag --redis-queue or GOVERNATOR_REDIS_QUEUE")
		}
		if deployStateUri == "" {
			color.Red("  Missing required flag --deploy-state-uri or DEPLOY_STATE_URI")
		}
		if cluster == "" {
			color.Red("  Missing required flag --cluster or CLUSTER")
		}
		os.Exit(1)
	}

	return etcdURI, redisURI, redisQueue, deployStateUri, cluster
}
开发者ID:octoblu,项目名称:governator,代码行数:30,代码来源:main.go

示例14: errExit

func errExit(ctx *cli.Context, err error, help bool) {
	fmt.Fprintf(os.Stderr, "\nError: %v\n\n", err)
	if help {
		cli.ShowAppHelp(ctx)
	}
	os.Exit(1)
}
开发者ID:jainvipin,项目名称:volplugin,代码行数:7,代码来源:volcli.go

示例15: main

func main() {
	app := cli.NewApp()
	app.Name = "rabbitmq-cli-consumer"
	app.Usage = "Consume RabbitMQ easily to any cli program"
	app.Author = "Richard van den Brand"
	app.Email = "[email protected]"
	app.Version = "1.1.0"
	app.Flags = []cli.Flag{
		cli.StringFlag{
			Name:  "executable, e",
			Usage: "Location of executable",
		},
		cli.StringFlag{
			Name:  "configuration, c",
			Usage: "Location of configuration file",
		},
		cli.BoolFlag{
			Name:  "verbose, V",
			Usage: "Enable verbose mode (logs to stdout and stderr)",
		},
	}
	app.Action = func(c *cli.Context) {
		if c.String("configuration") == "" && c.String("executable") == "" {
			cli.ShowAppHelp(c)
			os.Exit(1)
		}

		verbose := c.Bool("verbose")

		logger := log.New(os.Stderr, "", log.Ldate|log.Ltime)
		cfg, err := config.LoadAndParse(c.String("configuration"))

		command.Cconf = cfg

		if err != nil {
			logger.Fatalf("Failed parsing configuration: %s\n", err)
		}

		errLogger, err := createLogger(cfg.Logs.Error, verbose, os.Stderr)
		if err != nil {
			logger.Fatalf("Failed creating error log: %s", err)
		}

		infLogger, err := createLogger(cfg.Logs.Info, verbose, os.Stdout)
		if err != nil {
			logger.Fatalf("Failed creating info log: %s", err)
		}

		factory := command.Factory(c.String("executable"))

		client, err := consumer.New(cfg, factory, errLogger, infLogger)
		if err != nil {
			errLogger.Fatalf("Failed creating consumer: %s", err)
		}

		client.Consume()
	}

	app.Run(os.Args)
}
开发者ID:nucleus-be,项目名称:rabbitmq-cli-consumer,代码行数:60,代码来源:main.go


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