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


Golang cli.ShowSubcommandHelp函数代码示例

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


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

示例1: checkArgs

func checkArgs(c *cli.Context) {
	if len(c.Args()) == 0 {
		fmt.Println("You must provide at least one package name")
		cli.ShowSubcommandHelp(c)
		os.Exit(2)
	}
}
开发者ID:SokoloffA,项目名称:zrpm,代码行数:7,代码来源:main.go

示例2: slackMethod

func slackMethod() cli.Command {
	return cli.Command{
		Name:  "run",
		Usage: "[method]",
		Flags: []cli.Flag{
			cli.StringFlag{
				Name:   "token",
				Usage:  "Your Slack API token",
				EnvVar: "SLACK_TOKEN",
			},
		},
		Description: "Hits the SlackAPI using the format: https://slack.com/api/{method}",
		Action: func(ctx *cli.Context) {
			if len(ctx.Args()) == 0 {
				cli.ShowSubcommandHelp(ctx)
				return
			}

			method := ctx.Args()[0]
			token := ctx.String("token")

			client := slacker.NewAPIClient(token, "")
			b, err := client.RunMethod(method)
			if err != nil {
				fmt.Printf("Error running method: %s", err.Error())
				return
			}

			fmt.Println(string(b))
		},
	}
}
开发者ID:bobbytables,项目名称:slacker,代码行数:32,代码来源:main.go

示例3: eventCommand

func eventCommand() cli.Command {
	eventFlag := cli.StringFlag{
		Name:  "event.name",
		Usage: "event name",
	}
	return cli.Command{
		Name:    "event",
		Aliases: []string{"e"},
		Usage:   "event related actions",
		Action: func(c *cli.Context) {
			cli.ShowSubcommandHelp(c)
			os.Exit(1)
		},
		Subcommands: []cli.Command{
			cli.Command{
				Name:    "list",
				Aliases: []string{"l"},
				Usage:   "list latest events an agent has seen",
				Flags:   append([]cli.Flag{eventFlag}, queryOptionFlags()...),
				Action: func(c *cli.Context) {
					cc := consulClient(c)
					name := c.String(eventFlag.Name)
					events, _, err := cc.Event().List(name, queryOptions(c))
					if err != nil {
						log.Fatalf("failed to fetch agent events: %v", err)
					}
					prettyPrint(events)
				},
			},
		},
	}
}
开发者ID:macb,项目名称:consulctl,代码行数:32,代码来源:event.go

示例4: createBundle

func createBundle(c *cli.Context) {
	if !c.Args().Present() {
		cli.ShowSubcommandHelp(c)
		log.Fatalf("Usage: %v name (common name defaults to name, use --cn and "+
			"different name if you need multiple certs for same cn)", c.Command.FullName())
	}

	commonName := strings.Join(c.Args()[:], " ")
	var filename string
	if filename = c.String("filename"); len(filename) == 0 {
		filename = strings.Replace(commonName, " ", "_", -1)
		filename = strings.Replace(filename, "*", "wildcard", -1)
	}

	subject := pkix.Name{CommonName: commonName}
	if str := c.String("organization"); len(str) > 0 {
		subject.Organization = []string{str}
	}
	if str := c.String("locality"); len(str) > 0 {
		subject.Locality = []string{str}
	}
	if str := c.String("country"); len(str) > 0 {
		subject.Country = []string{str}
	}
	if str := c.String("province"); len(str) > 0 {
		subject.Province = []string{str}
	}
	if str := c.String("organizational-unit"); len(str) > 0 {
		subject.OrganizationalUnit = []string{str}
	}

	template := &x509.Certificate{
		Subject:  subject,
		NotAfter: time.Now().AddDate(0, 0, c.Int("expire")),
	}

	if c.Bool("ca") {
		template.IsCA = true
		filename = "ca"
	} else if c.Bool("client") {
		template.ExtKeyUsage = append(template.ExtKeyUsage, x509.ExtKeyUsageClientAuth)
		template.EmailAddresses = c.StringSlice("email")
	} else {
		// We default to server
		template.ExtKeyUsage = append(template.ExtKeyUsage, x509.ExtKeyUsageServerAuth)

		IPs := make([]net.IP, 0, len(c.StringSlice("ip")))
		for _, ipStr := range c.StringSlice("ip") {
			if i := net.ParseIP(ipStr); i != nil {
				IPs = append(IPs, i)
			}
		}
		template.IPAddresses = IPs
		template.DNSNames = c.StringSlice("dns")
	}
	err := easypki.GenerateCertifcate(c.GlobalString("root"), filename, template)
	if err != nil {
		log.Fatal(err)
	}
}
开发者ID:postfix,项目名称:easypki,代码行数:60,代码来源:main.go

示例5: cmdScriptRun

// cmdScriptRun serviced script run filename
func (c *ServicedCli) cmdScriptRun(ctx *cli.Context) {
	args := ctx.Args()
	if len(args) != 1 {
		fmt.Fprintln(os.Stderr, "Incorrect Usage.\n\n")
		if !ctx.Bool("help") {
			fmt.Fprintf(os.Stderr, "Incorrect Usage.\n\n")
		}
		cli.ShowSubcommandHelp(ctx)
		return
	}

	var svc *service.Service
	if svcID := ctx.String("service"); svcID != "" {
		//verify service or translate to ID
		var err error
		svc, err = c.searchForService(svcID)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			c.exit(1)
			return
		}
		if svc == nil {
			fmt.Fprintf(os.Stderr, "service %s not found\n", svcID)
			c.exit(1)
			return
		}
	}

	fileName := args[0]
	config := &script.Config{}
	if svc != nil {
		config.ServiceID = svc.ID
	}

	// exec unix script command to log output
	if isWithin := os.Getenv("IS_WITHIN_UNIX_SCRIPT"); isWithin != "TRUE" {
		os.Setenv("IS_WITHIN_UNIX_SCRIPT", "TRUE") // prevent inception problem

		// DO NOT EXIT ON ANY ERRORS - continue without logging
		logdir := utils.ServicedLogDir()
		if userrec, err := user.Current(); err != nil {
			fmt.Fprintf(os.Stderr, "Unable to retrieve userid to log output: %s", err)
		} else {
			logfile := time.Now().Format(fmt.Sprintf("%s/script-2006-01-02-150405-%s.log", logdir, userrec.Username))

			// unix exec ourselves
			cmd := []string{"/usr/bin/script", "--append", "--return", "--flush",
				"-c", strings.Join(os.Args, " "), logfile}

			fmt.Fprintf(os.Stderr, "Logging to logfile: %s\n", logfile)
			glog.V(1).Infof("syscall.exec unix script with command: %+v", cmd)
			if err := syscall.Exec(cmd[0], cmd[0:], os.Environ()); err != nil {
				fmt.Fprintf(os.Stderr, "Unable to log output with command:%+v err:%s\n", cmd, err)
			}
		}
	}

	glog.V(1).Infof("runScript filename:%s %+v\n", fileName, config)
	runScript(c, ctx, fileName, config)
}
开发者ID:carriercomm,项目名称:serviced,代码行数:61,代码来源:script.go

示例6: secretAdd

func secretAdd(c *cli.Context) error {

	repo := c.Args().First()
	owner, name, err := parseRepo(repo)
	if err != nil {
		return err
	}

	tail := c.Args().Tail()
	if len(tail) != 2 {
		cli.ShowSubcommandHelp(c)
		return nil
	}

	secret := &model.Secret{}
	secret.Name = tail[0]
	secret.Value = tail[1]
	secret.Images = c.StringSlice("image")
	secret.Events = c.StringSlice("event")

	if len(secret.Images) == 0 {
		return fmt.Errorf("Please specify the --image parameter")
	}

	client, err := newClient(c)
	if err != nil {
		return err
	}

	return client.SecretPost(owner, name, secret)
}
开发者ID:tnaoto,项目名称:drone,代码行数:31,代码来源:secret.go

示例7: createPastie

// Create a pastie.
func createPastie(c *cli.Context) {
	fn := strings.TrimSpace(c.Args().First())
	if fn == "" {
		cli.ShowSubcommandHelp(c)
		return
	}

	content, err := ioutil.ReadFile(fn)
	if err != nil {
		fmt.Printf("Can't read '%s'\n", fn)
		return
	}

	pastie, resp, _ := pst.Create(string(content), c.String("lang"), c.Bool("restricted"))

	if resp.StatusCode != http.StatusOK {
		fmt.Println(resp.Status)
	}

	shortURL, err := isgd.Short(pastie)
	if err != nil {
		panic(err)
	}

	fmt.Printf("File: %s\nPastie URL: %s\nShort URL: %s\n",
		fn, pastie, shortURL)

}
开发者ID:0x7cc,项目名称:x16,代码行数:29,代码来源:commands.go

示例8: echo_command

func echo_command(cfg *watch.Config, action func(*watch.Config)) cli.Command {
	return cli.Command{
		Name:      "echo",
		Usage:     "echo the full filepath",
		ArgsUsage: "DIR",
		Action: func(c *cli.Context) {

			args := c.Args()

			bail := func() {
				cli.ShowSubcommandHelp(c)
				os.Exit(1)
			}

			if !args.Present() {
				bail()
			}

			cfg.Actions = []watch.Action{
				&watch.EchoAction{},
			}
			cfg.Dir = args.First()
			action(cfg)
		},
	}
}
开发者ID:draxil,项目名称:springboard,代码行数:26,代码来源:springboard.go

示例9: zoneInfo

func zoneInfo(c *cli.Context) {
	if err := checkEnv(); err != nil {
		fmt.Println(err)
		return
	}
	var zone string
	if len(c.Args()) > 0 {
		zone = c.Args()[0]
	} else if c.String("zone") != "" {
		zone = c.String("zone")
	} else {
		cli.ShowSubcommandHelp(c)
		return
	}
	zones, err := api.ListZones(zone)
	if err != nil {
		fmt.Println(err)
		return
	}
	var output []table
	for _, z := range zones {
		output = append(output, table{
			"ID":           z.ID,
			"Zone":         z.Name,
			"Plan":         z.Plan.LegacyID,
			"Status":       z.Status,
			"Name Servers": strings.Join(z.NameServers, ", "),
			"Paused":       fmt.Sprintf("%t", z.Paused),
			"Type":         z.Type,
		})
	}
	makeTable(output, "ID", "Zone", "Plan", "Status", "Name Servers", "Paused", "Type")
}
开发者ID:tlianza,项目名称:cloudflare-go,代码行数:33,代码来源:flarectl.go

示例10: cloud_list

func cloud_list(c *cli.Context) {
	args := c.Args()
	L := len(args)
	if L != 0 {
		fmt.Println("Error: bad args to 'cloud list'")
		cli.ShowSubcommandHelp(c)
		return
	}
	appname := APPCFG.Name

	// get a directory listing
	finfos, err := ioutil.ReadDir(APPCFG.SourcePath + "/clouds")
	if err != nil {
		fmt.Println("while reading clouds directory: ", err)
	}

	fmt.Printf("\n%-16s %-15s %-12s   %s\n", "Name", "Host", "Status", "Master:Worker counts")
	for _, fi := range finfos {
		if fi.IsDir() {
			continue
		}
		cloudname := strings.Replace(fi.Name(), ".yaml", "", -1)
		cloudcfg, err := readCloudConfig(appname, cloudname)
		if err != nil {
			fmt.Println("while reading cloud config: ", err)
		}

		fmt.Printf("%-16s %-15s %-12s   %d:%d\n", cloudcfg.Name, cloudcfg.URI, cloudcfg.Status, cloudcfg.NumMaster, cloudcfg.NumWorker)
	}
}
开发者ID:verdverm,项目名称:starterKit,代码行数:30,代码来源:cloud.go

示例11: cloud_status

func cloud_status(c *cli.Context) {
	args := c.Args()
	L := len(args)
	if L != 1 {
		fmt.Println("Error: bad args to 'cloud status <cloudname>'")
		cli.ShowSubcommandHelp(c)
		return
	}

	appname := APPCFG.Name
	cloudname := args[0]

	cloudcfg, err := readCloudConfig(appname, cloudname)
	if err != nil {
		fmt.Println("while reading cloud config: ", err)
		return
	}

	// print status known in the config file
	fmt.Printf("\n%-16s %-15s %-12s   %s\n", "Name", "Host", "Status", "Master:Worker counts")
	fmt.Printf("%-16s %-15s %-12s   %d:%d\n\n", cloudcfg.Name, cloudcfg.URI, cloudcfg.Status, cloudcfg.NumMaster, cloudcfg.NumWorker)

	// print status from mesos

	providers.CloudStatus(cloudcfg)

	// print status for the app

	// print status from mesosphere ? or is the service status

}
开发者ID:verdverm,项目名称:starterKit,代码行数:31,代码来源:cloud.go

示例12: secretAdd

func secretAdd(c *cli.Context) error {
	repo := c.Args().First()
	owner, name, err := parseRepo(repo)
	if err != nil {
		return err
	}

	tail := c.Args().Tail()
	if len(tail) != 2 {
		cli.ShowSubcommandHelp(c)
		return nil
	}

	secret, err := secretParseCmd(tail[0], tail[1], c)
	if err != nil {
		return err
	}

	client, err := newClient(c)
	if err != nil {
		return err
	}

	return client.SecretPost(owner, name, secret)
}
开发者ID:donny-dont,项目名称:drone,代码行数:25,代码来源:secret_add.go

示例13: checkArgCount

func checkArgCount(c *cli.Context, num int) error {
	args := c.Args()
	if len(args) < num {
		if c.App != nil { // may be nill during tests, can cause panic
			cli.ShowSubcommandHelp(c)
		}
		return fmt.Errorf("Insufficient arguments: expected %d, provided %d", num, len(args))
	}
	if len(args) > num {
		if c.App != nil { // may be nill during tests, can cause panic
			cli.ShowSubcommandHelp(c)
		}
		return fmt.Errorf("Unknown arguments: %v", args[num:])
	}
	return nil
}
开发者ID:toliaqat,项目名称:photon-controller,代码行数:16,代码来源:iohelpers.go

示例14: nodeName

func nodeName(c *cli.Context) string {
	name := c.String(nodeFlag.Name)
	if name == "" {
		cli.ShowSubcommandHelp(c)
		log.Fatal("node is required")
	}
	return name
}
开发者ID:macb,项目名称:consulctl,代码行数:8,代码来源:utils.go

示例15: db_import

func db_import(c *cli.Context) {
	if len(c.Args()) != 0 {
		fmt.Println("Error: bad args to 'db import' !!!")
		cli.ShowSubcommandHelp(c)
		return
	}
	fmt.Println("Not implemented yet...")
}
开发者ID:verdverm,项目名称:starterKit,代码行数:8,代码来源:dbcmds.go


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