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 (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 }
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 }
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 (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 }
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 (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 }
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 }
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 }
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 (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 }
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 }
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) }
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 }
// 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 }
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{"updater", "service", "kbfs"} } else { v.components = strings.Split(ctx.String("components"), ",") } // Brew uses the auto installer by default if libkb.IsBrewBuild && v.installer == "" { v.installer = "auto" } return nil }
func (c *CmdAPICall) ParseArgv(ctx *cli.Context) error { var err error nargs := len(ctx.Args()) if nargs == 0 { return fmt.Errorf("endpoint is required") } c.endpoint = ctx.Args()[0] if c.method, err = c.validateMethod(ctx.String("method")); err != nil { return err } args := ctx.StringSlice("arg") for _, a := range args { pa, err := c.parseArgument(a) if err != nil { return err } c.addArgument(pa) } httpStatuses := ctx.IntSlice("status") for _, h := range httpStatuses { c.httpStatuses = append(c.httpStatuses, h) } appStatuses := ctx.IntSlice("appstatus") for _, a := range appStatuses { c.appStatuses = append(c.appStatuses, a) } payload := ctx.String("json-payload") if payload != "" { if c.JSONPayload, err = c.parseJSONPayload(payload); err != nil { return err } } return nil }
// ParseArgv parses arguments for the prove command. func (p *CmdProve) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) p.arg.Force = ctx.Bool("force") p.output = ctx.String("output") if nargs > 2 || nargs == 0 { return fmt.Errorf("prove takes 1 or 2 args: <service> [<username>]") } p.arg.Service = ctx.Args()[0] if nargs == 2 { p.arg.Username = ctx.Args()[1] } if libkb.RemoteServiceTypes[p.arg.Service] == keybase1.ProofType_ROOTER { p.arg.Auto = ctx.Bool("auto") if p.arg.Auto && len(p.arg.Username) == 0 { return fmt.Errorf("must specify the username when using auto flag") } } return nil }
func (c *CmdPGPDecrypt) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("pgp decrypt") } msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, outfile); err != nil { return err } c.signed = ctx.Bool("signed") c.signedBy = ctx.String("signed-by") return nil }
func (s *CmdSignup) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) var err error s.code = ctx.String("invite-code") if s.code == "" { // For development convenience. s.code = os.Getenv("KEYBASE_INVITATION_CODE") } s.defaultEmail = ctx.String("email") s.defaultUsername = ctx.String("username") s.defaultPassphrase = ctx.String("passphrase") s.defaultDevice = ctx.String("device") if s.defaultDevice == "" { s.defaultDevice = "home computer" } if ctx.Bool("batch") { s.fields = &PromptFields{ email: &Field{Value: &s.defaultEmail}, code: &Field{Value: &s.code}, username: &Field{Value: &s.defaultUsername}, deviceName: &Field{Value: &s.defaultDevice}, passphraseRetry: &Field{}, } s.passphrase = s.defaultPassphrase s.prompter = NewPrompter(s.fields.ToList(), s.G().UI.GetTerminalUI()) s.doPrompt = false } else { s.doPrompt = true } if nargs != 0 { err = BadArgsError{"Signup doesn't take arguments."} } return err }
func (c *CmdPGPDecrypt) ParseArgv(ctx *cli.Context) error { msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, outfile); err != nil { return err } c.trackOptions = keybase1.TrackOptions{ LocalOnly: ctx.Bool("local"), BypassConfirm: ctx.Bool("y"), } c.signed = ctx.Bool("signed") c.signedBy = ctx.String("signed-by") return nil }
func (s *CmdSigsList) ParseArgv(ctx *cli.Context) error { nargs := len(ctx.Args()) var err error s.revoked = ctx.Bool("revoked") s.json = ctx.Bool("json") s.verbose = ctx.Bool("verbose") s.allKeys = ctx.Bool("all-keys") s.headers = ctx.Bool("headers") s.filter = ctx.String("filter") if err = s.ParseTypes(ctx); err != nil { return err } if nargs == 1 { s.username = ctx.Args()[0] } else if nargs > 1 { err = fmt.Errorf("List takes at most 1 arg, a username.") } return err }
func (c *CmdPGPEncrypt) ParseArgv(ctx *cli.Context) error { c.noSelf = ctx.Bool("no-self") if c.noSelf && len(ctx.Args()) == 0 { return errors.New("Encrypt needs at least one recipient, or --no-self=false") } msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, outfile); err != nil { return err } c.recipients = ctx.Args() c.sign = ctx.Bool("sign") c.keyQuery = ctx.String("key") c.binaryOut = ctx.Bool("binary") return nil }
// ctlParseArgv returns map with include/exclude components func ctlParseArgv(ctx *cli.Context) map[string]bool { components := defaultCtlComponents(true) if ctx.String("exclude") != "" { excluded := strings.Split(ctx.String("exclude"), ",") for _, exclude := range excluded { components[exclude] = false } } if ctx.String("include") != "" { included := strings.Split(ctx.String("include"), ",") components = defaultCtlComponents(false) for _, include := range included { components[include] = true } } return components }
func (v *CmdUninstall) ParseArgv(ctx *cli.Context) error { v.format = ctx.String("format") if ctx.String("components") == "" { if libkb.IsBrewBuild { v.components = []string{"service"} } else { v.components = []string{"service", "kbfs", "updater"} } } else { v.components = strings.Split(ctx.String("components"), ",") } return nil }
func (s *CmdSign) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("sign") } s.detached = ctx.Bool("detached") s.binary = ctx.Bool("binary") msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") return s.FilterInit(msg, infile, outfile) }
func (c *CmdPGPEncrypt) ParseArgv(ctx *cli.Context) error { c.noSelf = ctx.Bool("no-self") if c.noSelf && len(ctx.Args()) == 0 { return errors.New("Encrypt needs at least one recipient, or --no-self=false") } msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, outfile); err != nil { return err } c.recipients = ctx.Args() c.trackOptions = keybase1.TrackOptions{ LocalOnly: ctx.Bool("local"), BypassConfirm: ctx.Bool("y"), } c.sign = ctx.Bool("sign") c.skipTrack = ctx.Bool("skip-track") c.keyQuery = ctx.String("key") c.binaryOut = ctx.Bool("binary") return nil }
func (c *CmdPGPVerify) ParseArgv(ctx *cli.Context) error { msg := ctx.String("message") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, "/dev/null"); err != nil { return err } c.trackOptions = keybase1.TrackOptions{ LocalOnly: ctx.Bool("local"), BypassConfirm: ctx.Bool("y"), } c.signedBy = ctx.String("signed-by") c.detachedFilename = ctx.String("detached") if len(c.detachedFilename) > 0 { data, err := ioutil.ReadFile(c.detachedFilename) if err != nil { return err } c.detachedData = data } return nil }
func (c *CmdPGPVerify) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) > 0 { return UnexpectedArgsError("pgp verify") } msg := ctx.String("message") infile := ctx.String("infile") if err := c.FilterInit(msg, infile, "/dev/null"); err != nil { return err } c.signedBy = ctx.String("signed-by") c.detachedFilename = ctx.String("detached") if len(c.detachedFilename) > 0 { data, err := ioutil.ReadFile(c.detachedFilename) if err != nil { return err } c.detachedData = data } return nil }
func (c *CmdEncrypt) ParseArgv(ctx *cli.Context) error { if len(ctx.Args()) == 0 { return errors.New("Encrypt needs at least one recipient") } c.recipients = ctx.Args() msg := ctx.String("message") outfile := ctx.String("outfile") infile := ctx.String("infile") c.noSelfEncrypt = ctx.Bool("no-self") c.binary = ctx.Bool("binary") if err := c.filter.FilterInit(msg, infile, outfile); err != nil { return err } return nil }