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


Golang Context.Bool方法代碼示例

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


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

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

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

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

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

示例5: ParseArgv

func (v *cmdUpdateNotify) ParseArgv(ctx *cli.Context) error {
	v.force = ctx.Bool("force")
	v.event = ctx.Args().First()
	if v.event == "" {
		return fmt.Errorf("No event specified")
	}
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:8,代碼來源:cmd_update.go

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

示例7: ParseArgv

func (c *CmdSearch) ParseArgv(ctx *cli.Context) error {
	c.query = strings.Join(ctx.Args(), " ")
	if c.query == "" {
		return fmt.Errorf("Search query must not be empty.")
	}
	c.json = ctx.Bool("json")
	return nil
}
開發者ID:Varjelus,項目名稱:keybase-client,代碼行數:8,代碼來源:cmd_search.go

示例8: ParseArgv

func (c *CmdDeviceRemove) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Device remove only takes one argument: the device ID or name.")
	}
	c.idOrName = ctx.Args()[0]
	c.force = ctx.Bool("force")
	return nil
}
開發者ID:qbit,項目名稱:client,代碼行數:8,代碼來源:cmd_device_remove.go

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

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

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

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

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

示例14: ParseArgv

func (v *CmdID) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	if nargs > 1 {
		return fmt.Errorf("Identify only takes one argument, the user to lookup.")
	}

	if nargs == 1 {
		v.user = ctx.Args()[0]
	}
	v.trackStatement = ctx.Bool("track-statement")
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:12,代碼來源:cmd_id.go

示例15: ParseArgv

func (c *CmdDeviceRemove) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) != 1 {
		return fmt.Errorf("Device remove only takes one argument, the device ID.")
	}
	id, err := keybase1.DeviceIDFromString(ctx.Args()[0])
	if err != nil {
		return err
	}
	c.id = id
	c.force = ctx.Bool("force")
	return nil
}
開發者ID:paul-pearce,項目名稱:client-beta,代碼行數:12,代碼來源:cmd_device_remove.go


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