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


Golang Context.Args方法代碼示例

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


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

示例1: 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

示例2: ParseArgv

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

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

示例3: ParseArgv

func (c *CmdFakeTrackingChanged) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Must provide exactly one username.")
	}
	c.arg.Username = ctx.Args()[0]
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:7,代碼來源:cmd_fake_following_changed.go

示例4: ParseArgv

// ParseArgv gets the secret phrase from the command args.
func (c *CmdDeviceAdd) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Device add only takes one argument, the secret phrase.")
	}
	c.phrase = ctx.Args()[0]
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:8,代碼來源:cmd_device_add.go

示例5: ParseArgv

func (c *CmdRevoke) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Revoke takes exactly one key.")
	}
	c.id = ctx.Args()[0]
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:7,代碼來源:cmd_revoke.go

示例6: 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

示例7: ParseArgv

func (c *CmdStatus) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 0 {
		return UnexpectedArgsError("status")
	}
	c.json = ctx.Bool("json")
	return nil
}
開發者ID:Varjelus,項目名稱:keybase-client,代碼行數:7,代碼來源:cmd_status.go

示例8: ParseArgv

func (c *CmdLogin) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	if nargs > 1 {
		return errors.New("Invalid arguments.")
	}

	provisionByEmail := ctx.Bool("provision-by-email")

	if nargs == 1 {
		c.username = ctx.Args()[0]
		if provisionByEmail {
			// if --provision-by-email flag set, then they can
			// use an email address for provisioning.
			if !libkb.CheckEmail.F(c.username) {
				return errors.New("Invalid email format. Please login again via `keybase login --provision-by-email [email]`")
			}
		} else {
			// they must use a username
			if libkb.CheckEmail.F(c.username) {
				return errors.New("You must use a username. Please login again via `keybase login [username]`")
			}
			if !libkb.CheckUsername.F(c.username) {
				return errors.New("Invalid username format. Please login again via `keybase login [username]`")
			}
		}

		if ctx.Bool("emulate-gui") {
			c.clientType = keybase1.ClientType_GUI
		}
	}
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:32,代碼來源:cmd_login.go

示例9: ParseArgv

func (v *CmdUntrack) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Unfollow only takes one argument, the user to unfollow.")
	}
	v.user = ctx.Args()[0]
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:7,代碼來源:cmd_unfollow.go

示例10: 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

示例11: 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

示例12: ParseArgv

func (c *CmdPGPDrop) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("drop takes exactly one key")
	}
	c.id = ctx.Args()[0]
	return nil
}
開發者ID:polluks,項目名稱:client,代碼行數:7,代碼來源:cmd_pgp_drop.go

示例13: ParseArgv

func (v *CmdTrack) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Track only takes one argument, the user to track.")
	}
	v.user = ctx.Args()[0]
	v.options = keybase1.TrackOptions{LocalOnly: ctx.Bool("local"), BypassConfirm: ctx.Bool("y")}
	return nil
}
開發者ID:moul,項目名稱:client,代碼行數:8,代碼來源:cmd_track.go

示例14: ParseArgv

// ParseArgv parses the command args.
func (c *CmdListTrackers) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) == 1 {
		c.assertion = ctx.Args()[0]
	}

	c.verbose = ctx.Bool("verbose")
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:9,代碼來源:cmd_list_followers.go

示例15: ParseArgv

func (c *CmdBTC) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Must provide exactly one address.")
	}
	c.address = ctx.Args()[0]
	c.force = ctx.Bool("force")
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:8,代碼來源:cmd_btc.go


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