// parseArgs parses the arguments from the walletdb Open/Create methods.
14173
func parseArgs(funcName string, args ...interface{}) (string, error) {
	if len(args) != 1 {
		return "", fmt.Errorf("invalid arguments to %s.%s -- "+
			"expected database path", dbType, funcName)
	}

	dbPath, ok := args[0].(string)
	if !ok {
		return "", fmt.Errorf("first argument to %s.%s is invalid -- "+
			"expected database path string", dbType, funcName)
	}

	return dbPath, nil
}
1149429
func (c *configCommand) parseResetKeys() error {
	if len(c.reset) == 0 {
		return nil
	}
	var resetKeys []string
	for _, value := range c.reset {
		keys := strings.Split(strings.Trim(value, ","), ",")
		resetKeys = append(resetKeys, keys...)
	}

	for _, k := range resetKeys {
		if k == config.AgentVersionKey {
			return errors.Errorf("%q cannot be reset", config.AgentVersionKey)
		}
		if strings.Contains(k, "=") {
			return errors.Errorf(
				`--reset accepts a comma delimited set of keys "a,b,c", received: %q`, k)
		}
	}
	c.resetKeys = resetKeys
	return nil
}
1349264
func (c *CmdSimpleFSSymlink) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	if nargs != 2 {
		return errors.New("ln requires exactly 2 arguments")
	}
	targetStr := ctx.Args()[0]
	linkStr := ctx.Args()[1]

	rev := int64(0)
	timeString := ""
	relTimeString := ""
	linkPath, err := makeSimpleFSPathWithArchiveParams(
		linkStr, rev, timeString, relTimeString)
	if err != nil {
		return err
	}

	linkPathType, err := linkPath.PathType()
	if err != nil {
		return err
	}
	if linkPathType != keybase1.PathType_KBFS {
		return errors.New("keybase fs ln: link must be a KBFS path")
	}
	c.link = linkPath

	c.target = targetStr

	return err
}
1138748
func (c *CmdSimpleFSRecover) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) < 1 {
		return errors.New("recover requires at least one KBFS path argument")
	}

	// TODO: "rev" should be a real int64, need to update the
	// `cli` library for that.
	rev := int64(ctx.Int("rev"))
	timeString := ctx.String("time")
	relTimeString := getRelTime(ctx)
	if rev == 0 && timeString == "" && relTimeString == "" {
		return errors.New(
			"must specify exactly one of -rev, -time, or -reltime")
	}

	for _, src := range ctx.Args() {
		p, err := makeSimpleFSPathWithArchiveParams(
			src, rev, timeString, relTimeString)
		if err != nil {
			return err
		}
		c.src = append(c.src, p)
	}
	return nil
}
841326
func parseArgs(argv []string) (string, []string) {
	if len(argv) == 1 {
		if argv[0] == "--help" || argv[0] == "-h" {
			// rearrange "deis --help" as "deis help"
			argv[0] = "help"
		} else if argv[0] == "--version" || argv[0] == "-v" {
			// rearrange "deis --version" as "deis version"
			argv[0] = "version"
		}
	}

	if len(argv) >= 2 {
		// Rearrange "deis help <command>" to "deis <command> --help".
		if argv[0] == "help" || argv[0] == "--help" || argv[0] == "-h" {
			argv = append(argv[1:], "--help")
		}
	}

	if len(argv) > 0 {
		argv[0] = replaceShortcut(argv[0])

		index := strings.Index(argv[0], ":")

		if index != -1 {
			command := argv[0]
			return command[:index], argv
		}

		return argv[0], argv
	}

	return "", argv
}
817112
func parseArgs(argv []string) ([]string, bool) {
	if argv == nil {
		argv = os.Args[1:]
	}

	if len(argv) == 1 {
		// rearrange "deisctl --help" as "deisctl help"
		if argv[0] == "--help" || argv[0] == "-h" {
			argv[0] = "help"
		}
	}

	if len(argv) >= 2 {
		// rearrange "deisctl help <command>" as "deisctl <command> --help"
		if argv[0] == "help" || argv[0] == "--help" || argv[0] == "-h" {
			argv = append(argv[1:], "--help")
		}
	}

	helpFlag := false
	for _, a := range argv {
		if a == "help" || a == "--help" || a == "-h" {
			helpFlag = true
			break
		}
	}

	return argv, helpFlag
}
815369
func ParseArgs(args []string) (string, []string, bool) {

	if len(args) == 0 {
		return "", []string{}, false
	}

	pluginName := ""
	pluginArgs := []string{}
	for idx, arg := range args {

		if strings.Contains(arg, bitrisePluginPrefix) {
			pluginSplits := strings.Split(arg, ":")

			if len(pluginSplits) != 2 {
				return "", []string{}, false
			}

			pluginName = pluginSplits[1]
			if len(args) > idx {
				pluginArgs = args[idx+1 : len(args)]
			}
			return pluginName, pluginArgs, true
		}
	}

	return "", []string{}, false
}
452279
func (c *CmdSimpleFSPs) ParseArgv(ctx *cli.Context) error {

	c.recurse = ctx.Bool("recurse")

	return nil
}
507625
func ParseFlagsWithArgs(cmd string) []string {
	flag.Parse()

	if *Version {
		AppVersion.Print()
		os.Exit(0)
	}

	args := flag.Args()
	if len(args) == 0 {
		log.Exitf("%s expected at least one positional argument", cmd)
	}

	return args
}
1315575
func (c *defaultsCommand) parseArgsForRegion(args []string) ([]string, error) {
	var err error
	if len(args) > 0 {
		// determine if the first arg is cloud/region or region and return
		// appropriate positional args.
		args, err = c.parseCloudRegion(args)
		if err != nil {
			return nil, errors.Trace(err)
		}
	}
	return args, nil
}
290177
func (c *CmdSimpleFSQuota) ParseArgv(ctx *cli.Context) error {
	c.git = ctx.Bool("git")
	c.bytes = ctx.Bool("bytes")
	c.archived = ctx.Bool("archived")
	c.json = ctx.Bool("json")

	if len(ctx.String("team")) > 0 {
		teamName, err := keybase1.TeamNameFromString(ctx.String("team"))
		if err != nil {
			return err
		}
		c.teamName = teamName
	}

	return nil
}
367888
func (c *Command) parseFlags(args []string) error {
	return c.flagSet.Parse(args)
}
488486
func (p *Parser) parseAlias() (string, error) {
	// Check if the next token is "AS". If not, then Unscan and exit.
	if tok, _, _ := p.ScanIgnoreWhitespace(); tok != AS {
		p.Unscan()
		return "", nil
	}

	// Then we should have the alias identifier.
	lit, err := p.ParseIdent()
	if err != nil {
		return "", err
	}
	return lit, nil
}
1272379
func parseAwsArnString(arn string) (awsArn, error) {
	if !strings.HasPrefix(arn, "arn:") {
		return awsArn{}, fmt.Errorf("expected arn: prefix, received: %s", arn)
	}
	arnParts := strings.SplitN(arn, ":", 6)
	if len(arnParts) != 6 {
		return awsArn{}, fmt.Errorf("expected 6 colon delimited sections, received: %s", arn)
	}
	return awsArn{
		account:   arnParts[4],
		partition: arnParts[1],
		region:    arnParts[3],
		resource:  arnParts[5],
		service:   arnParts[2],
	}, nil
}
1006161
func ParseAppSKey(input string) (key AppSKey, err error) {
	aes128key, err := ParseAES128Key(input)
	if err != nil {
		return
	}
	key = AppSKey(aes128key)
	return
}
827556
func parseAnnotations(annotationArgs []string) (map[string]string, []string, error) {
	return cmdutil.ParsePairs(annotationArgs, "annotation", true)
}
343104
func (storage *MessageBodyStorage) BucketArnAllKeys() *gocf.StringExpr {
	return gocf.Join("",
		gocf.String("arn:aws:s3:::"),
		storage.bucketNameExpr,
		gocf.String("/*"))
}