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 }
// 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 }
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 }
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 }
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 }
func (s *CmdPGPList) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("pgp list") } return nil }
func (c *CmdStatus) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("status") } c.json = ctx.Bool("json") return nil }
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 }
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 }
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 }
func (c *CmdWatchdog) ParseArgv(ctx *cli.Context) error { c.restarts = ctx.Int("num-restarts") if c.restarts == 0 { c.restarts = numRestartsDefault } return nil }
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 }
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 }
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 }
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 }
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 }
func (v *CmdTrack) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) != 1 { return fmt.Errorf("Track only takes one argument, the user to follow.") } v.user = ctx.Args()[0] v.options = keybase1.TrackOptions{LocalOnly: ctx.Bool("local"), BypassConfirm: ctx.Bool("y")} v.skipProofCache = ctx.Bool("skip-proof-cache") return nil }
func (v *CmdConfigGet) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) < 1 { return fmt.Errorf("Not enough arguments.") } v.key = ctx.Args()[0] if v.writer == nil { v.writer = GlobUI.OutputWriter() } return nil }
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 }
func (c *CmdPGPDrop) ParseArgv(ctx *cli.Context) (err error) { if len(ctx.Args()) != 1 { return fmt.Errorf("drop takes exactly one key") } c.id, err = keybase1.KIDFromStringChecked(ctx.Args()[0]) if err != nil { return fmt.Errorf("bad key: %v", err) } return nil }
func (v *CmdDumpKeyfamily) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) if nargs > 1 { return fmt.Errorf("dump-keyfamily only takes one argument, the user to lookup") } if nargs == 1 { v.user = ctx.Args()[0] } return nil }
func (c *CmdFavoriteDelete) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) != 1 { return errors.New("Favorite remove only takes one argument, the folder name.") } f, err := ParseTLF(ctx.Args()[0]) if err != nil { return err } c.folder = f return nil }
func (c *CmdSigsRevoke) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) == 0 { return fmt.Errorf("No arguments given to sigs revoke.") } for _, arg := range ctx.Args() { c.sigIDs = append(c.sigIDs, keybase1.SigID(arg)) } return nil }
func (c *CmdLogin) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) if nargs > 1 { return errors.New("Invalid arguments.") } if nargs == 1 { c.username = ctx.Args()[0] } return nil }
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] if len(args) < 2 { return fmt.Errorf("No bundle version specified.") } v.bundleVersion = args[1] return nil }
func (c *CmdLogSend) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("log send") } c.numLines = ctx.Int("n") if c.numLines < 1 { c.numLines = defaultLines } else if c.numLines > maxLines { c.numLines = maxLines } return nil }
func (c *CmdSecretKey) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) != 1 { return fmt.Errorf("Must specify either 'encryption' or 'signing'.") } arg := ctx.Args()[0] if arg == "encryption" || arg == "signing" { c.keytype = arg } else { return fmt.Errorf("Must specify either 'encryption' or 'signing'.") } return nil }
func (c *CmdFavoriteAdd) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) != 1 { return errors.New("Favorite add only takes one argument, the folder name.") } f, err := ParseTLF(ctx.Args()[0]) if err != nil { return err } f.Created = true c.folder = f return nil }
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 }
func (c *CmdSigsRevoke) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) == 0 { return fmt.Errorf("No arguments given to sigs revoke.") } for _, arg := range ctx.Args() { if len(arg) < keybase1.SigIDQueryMin { return fmt.Errorf("sig id %q is too short; must be at least 16 characters long", arg) } c.queries = append(c.queries, arg) } return nil }