當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.String方法代碼示例

本文整理匯總了Golang中github.com/keybase/cli.Context.String方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.String方法的具體用法?Golang Context.String怎麽用?Golang Context.String使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/keybase/cli.Context的用法示例。


在下文中一共展示了Context.String方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ParseTypes

func (s *CmdSigsList) ParseTypes(ctx *cli.Context) error {
	tmp := ctx.String("type")
	if len(tmp) == 0 {
		return nil
	}

	types := map[string]bool{
		"track":          true,
		"proof":          true,
		"cryptocurrency": true,
		"self":           true,
	}

	ret := make(map[string]bool)
	v := strings.Split(tmp, ",")
	for _, i := range v {
		ok, found := types[i]
		if !ok || !found {
			return fmt.Errorf("Unknown signature type: %s", i)
		}
		ret[i] = true
	}
	s.types = ret
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:25,代碼來源:cmd_sigs_list.go

示例2: ParseArgv

func (c *CmdVerify) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 0 {
		return UnexpectedArgsError("verify")
	}

	msg := ctx.String("message")
	infile := ctx.String("infile")
	outfile := ctx.String("outfile")
	if ctx.Bool("no-output") {
		if len(outfile) > 0 {
			return errors.New("Cannot specify an outfile and no-output")
		}
		outfile = "/dev/null"
	}
	if err := c.FilterInit(msg, infile, outfile); err != nil {
		return err
	}
	c.signedBy = ctx.String("signed-by")
	detachedFilename := ctx.String("detached")

	if len(detachedFilename) > 0 {
		data, err := ioutil.ReadFile(detachedFilename)
		if err != nil {
			return err
		}
		c.detachedData = data
	}

	return nil
}
開發者ID:mark-adams,項目名稱:client,代碼行數:30,代碼來源:cmd_verify.go

示例3: ParseArgv

func (v *CmdLaunchdStatus) ParseArgv(ctx *cli.Context) error {
	args := ctx.Args()
	if len(args) < 1 {
		return fmt.Errorf("No service name specified.")
	}

	// Resolve any label "aliases"
	labelStr := args[0]
	switch labelStr {
	case "service":
		labelStr = install.DefaultServiceLabel(v.G().Env.GetRunMode())
	case "kbfs":
		labelStr = install.DefaultKBFSLabel(v.G().Env.GetRunMode())
	case "updater":
		labelStr = install.DefaultUpdaterLabel(v.G().Env.GetRunMode())
	}

	label, err := install.NewServiceLabel(labelStr)
	if err != nil {
		return err
	}
	v.label = label

	v.format = ctx.String("format")
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:26,代碼來源:cmd_launchd_osx.go

示例4: ParseArgv

func (v *CmdLaunchdStatus) ParseArgv(ctx *cli.Context) error {
	args := ctx.Args()
	if len(args) < 1 {
		return fmt.Errorf("No service name specified.")
	}
	v.name = args[0]
	v.format = ctx.String("format")
	return nil
}
開發者ID:mark-adams,項目名稱:client,代碼行數:9,代碼來源:cmd_launchd_osx.go

示例5: ParseArgv

func (s *CmdPGPImport) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 0 {
		return fmt.Errorf("Invalid arguments")
	}

	s.arg.PushSecret = ctx.Bool("push-secret")
	s.infile = ctx.String("infile")
	return nil
}
開發者ID:mark-adams,項目名稱:client,代碼行數:9,代碼來源:cmd_pgp_import.go

示例6: ParseArgv

func (v *CmdVersion) ParseArgv(c *cli.Context) error {
	switch c.String("format") {
	case "s":
		v.mode = modeShort
	case "v":
		v.mode = modeVerbose
	}
	v.svc = !c.Bool("S")
	return nil
}
開發者ID:mark-adams,項目名稱:client,代碼行數:10,代碼來源:cmd_version.go

示例7: ParseArgv

func (d *Service) ParseArgv(ctx *cli.Context) error {
	d.chdirTo = ctx.String("chdir")
	if ctx.Bool("auto-forked") {
		d.ForkType = keybase1.ForkType_AUTO
	} else if ctx.Bool("watchdog-forked") {
		d.ForkType = keybase1.ForkType_WATCHDOG
	} else if ctx.Bool("launchd-forked") {
		d.ForkType = keybase1.ForkType_LAUNCHD
	}
	return nil
}
開發者ID:mattcurrycom,項目名稱:client,代碼行數:11,代碼來源:main.go

示例8: ParseArgv

func (v *CmdInstall) ParseArgv(ctx *cli.Context) error {
	v.force = ctx.Bool("force")
	v.format = ctx.String("format")
	v.binPath = ctx.String("bin-path")
	v.installer = ctx.String("installer")
	if ctx.String("components") == "" {
		v.components = []string{"cli", "service", "kbfs"}
	} else {
		v.components = strings.Split(ctx.String("components"), ",")
	}
	return nil
}
開發者ID:polluks,項目名稱:client,代碼行數:12,代碼來源:cmd_install_osx.go

示例9: ParseArgv

func (c *CmdDecrypt) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 0 {
		return UnexpectedArgsError("decrypt")
	}
	interactive := ctx.Bool("interactive")
	c.spui = &SaltpackUI{
		Contextified: libkb.NewContextified(c.G()),
		interactive:  interactive,
		force:        ctx.Bool("force"),
	}
	c.opts.Interactive = interactive
	c.opts.UsePaperKey = ctx.Bool("paperkey")
	msg := ctx.String("message")
	outfile := ctx.String("outfile")
	infile := ctx.String("infile")
	senderfile := ctx.String("encryptor-outfile")
	if err := c.filter.FilterInit(msg, infile, outfile); err != nil {
		return err
	}
	if senderfile != "" {
		c.senderfile = NewFileSink(senderfile)
	}

	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:25,代碼來源:cmd_decrypt.go

示例10: ParseArgv

func (v *CmdUpdateRun) ParseArgv(ctx *cli.Context) error {
	currentVersion := ctx.String("current-version")
	if currentVersion != "" {
		v.options.Version = currentVersion
	}

	destinationPath := ctx.String("destination-path")
	if destinationPath != "" {
		v.options.DestinationPath = destinationPath
	}

	source := ctx.String("source")
	if source != "" {
		v.options.Source = source
	}

	v.options.URL = ctx.String("url")
	v.options.Force = ctx.Bool("force")

	if v.options.DestinationPath == "" {
		return fmt.Errorf("No default destination path for this environment")
	}

	return nil
}
開發者ID:Varjelus,項目名稱:keybase-client,代碼行數:25,代碼來源:cmd_update.go

示例11: ParseArgv

func (s *CmdListTracking) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) == 1 {
		s.assertion = ctx.Args()[0]
	} else if len(ctx.Args()) > 1 {
		return fmt.Errorf("list-following takes at most one argument")
	}

	s.json = ctx.Bool("json")
	s.verbose = ctx.Bool("verbose")
	s.headers = ctx.Bool("headers")
	s.filter = ctx.String("filter")

	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:14,代碼來源:cmd_list_following.go

示例12: ParseArgv

func (s *CmdPGPExport) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	var err error

	s.arg.Options.Secret = ctx.Bool("secret")
	s.arg.Options.Query = ctx.String("query")
	s.outfile = ctx.String("outfile")

	if nargs > 0 {
		err = fmt.Errorf("export doesn't take args")
	}

	return err
}
開發者ID:mark-adams,項目名稱:client,代碼行數:14,代碼來源:cmd_pgp_export.go

示例13: ParseArgv

func (s *CmdPGPSign) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 0 {
		return UnexpectedArgsError("pgp sign")
	}

	s.opts.BinaryOut = ctx.Bool("binary")
	s.opts.BinaryIn = !ctx.Bool("text")

	msg := ctx.String("message")
	outfile := ctx.String("outfile")

	infile := ctx.String("infile")

	clr := ctx.Bool("clearsign")
	dtch := ctx.Bool("detached")

	if clr && dtch {
		return fmt.Errorf("Can't specify both -c and -d")
	}

	if clr {
		s.opts.Mode = keybase1.SignMode_CLEAR
	} else if dtch {
		s.opts.Mode = keybase1.SignMode_DETACHED
	} else {
		s.opts.Mode = keybase1.SignMode_ATTACHED
	}

	s.opts.KeyQuery = ctx.String("key")

	return s.FilterInit(msg, infile, outfile)
}
開發者ID:mark-adams,項目名稱:client,代碼行數:32,代碼來源:cmd_pgp_sign.go

示例14: ParseArgv

func (s *CmdListTracking) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	var err error

	s.json = ctx.Bool("json")
	s.verbose = ctx.Bool("verbose")
	s.headers = ctx.Bool("headers")
	s.filter = ctx.String("filter")

	if nargs > 0 {
		err = fmt.Errorf("List tracking doesn't take any arguments.")
	}

	return err
}
開發者ID:mark-adams,項目名稱:client,代碼行數:15,代碼來源:cmd_list_tracking.go

示例15: ParseArgv

// ParseArgv parses arguments for the prove command.
func (p *CmdProve) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	var err error
	p.arg.Force = ctx.Bool("force")
	p.output = ctx.String("output")

	if nargs > 2 || nargs == 0 {
		err = fmt.Errorf("prove takes 1 or 2 args: <service> [<username>]")
	} else {
		p.arg.Service = ctx.Args()[0]
		if nargs == 2 {
			p.arg.Username = ctx.Args()[1]
		}
	}
	return err
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:17,代碼來源:cmd_prove.go


注:本文中的github.com/keybase/cli.Context.String方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。