本文整理匯總了Golang中github.com/keybase/cli.Context類的典型用法代碼示例。如果您正苦於以下問題:Golang Context類的具體用法?Golang Context怎麽用?Golang Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例2: 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
}
示例3: 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
}
示例4: 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
}
示例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
}
示例6: ParseArgv
func (s *CmdPGPList) ParseArgv(ctx *cli.Context) error {
if len(ctx.Args()) > 0 {
return UnexpectedArgsError("pgp list")
}
return nil
}
示例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
}
示例8: 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
}
示例9: 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
}
示例10: 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
}
示例11: ParseArgv
func (c *CmdWatchdog) ParseArgv(ctx *cli.Context) error {
c.restarts = ctx.Int("num-restarts")
if c.restarts == 0 {
c.restarts = numRestartsDefault
}
return nil
}
示例12: 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
}
示例13: ParseArgv
func (v *CmdLaunchdAction) ParseArgv(ctx *cli.Context) error {
args := ctx.Args()
if len(args) < 1 {
return fmt.Errorf("Need to specify launchd label")
}
v.label = args[0]
return nil
}
示例14: 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
}
示例15: ParseArgv
func (v *CmdLogin) ParseArgv(ctx *cli.Context) (err error) {
nargs := len(ctx.Args())
if nargs > 1 {
err = errors.New("Invalid arguments.")
} else if nargs == 1 {
v.Username = ctx.Args()[0]
}
return err
}