// ParseArgv gets the required path.
764263
func (c *CmdSimpleFSSyncShow) ParseArgv(ctx *cli.Context) error {
	if len(ctx.Args()) > 1 {
		return fmt.Errorf("wrong number of arguments")
	}

	if len(ctx.Args()) == 1 {
		p, err := makeSimpleFSPath(ctx.Args()[0])
		if err != nil {
			return err
		}
		c.path = p
	} else {
		c.getAll = true
	}
	return nil
}
1082101
func parseS3Path(path string) (string, string, error) {
	// S3 path names are of the form s3://bucket/key
	stringsArray := strings.SplitN(path, "/", 4)
	if len(stringsArray) < 4 {
		return "", "", fmt.Errorf("Invalid s3 path %s", path)
	}
	bucketName := stringsArray[2]
	// Everything after the third slash is the key
	key := stringsArray[3]
	return bucketName, key, nil
}
1107332
func DefaultPathEnv(platform string) string {
	if runtime.GOOS == "windows" {
		if platform != runtime.GOOS && LCOWSupported() {
			return defaultUnixPathEnv
		}
		// Deliberately empty on Windows containers on Windows as the default path will be set by
		// the container. Docker has no context of what the default path should be.
		return ""
	}
	return defaultUnixPathEnv

}
267935
func NewSearchArg(Path string, Query string) *SearchArg {
	s := new(SearchArg)
	s.Path = Path
	s.Query = Query
	s.Start = 0
	s.MaxResults = 100
	s.Mode = &SearchMode{Tagged: dropbox.Tagged{"filename"}}
	return s
}
292267
func parseArgs(funcName string, args ...interface{}) (string, wire.BitcoinNet, error) {
	if len(args) != 2 {
		return "", 0, fmt.Errorf("invalid arguments to %s.%s -- "+
			"expected database path and block network", dbType,
			funcName)
	}

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

	network, ok := args[1].(wire.BitcoinNet)
	if !ok {
		return "", 0, fmt.Errorf("second argument to %s.%s is invalid -- "+
			"expected block network", dbType, funcName)
	}

	return dbPath, network, nil
}
973143
func (c *CmdSimpleFSList) ParseArgv(ctx *cli.Context) error {
	nargs := len(ctx.Args())
	var err error

	c.recurse = ctx.Bool("rec") || ctx.Bool("recursive")
	c.winStyle = ctx.Bool("windows")
	c.options.all = ctx.Bool("all")
	c.options.long = ctx.Bool("long")
	c.options.one = ctx.Bool("one")
	c.options.dir = true // treat dirs as regular entries
	c.options.color = !ctx.Bool("nocolor")
	c.options.sortReverse = ctx.Bool("sort-reverse")
	c.options.sortTime = ctx.Bool("sort-time")
	c.options.sortSize = ctx.Bool("sort-size")
	c.options.dirsFirst = ctx.Bool("dirs-first")

	if nargs < 1 {
		return errors.New("ls 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"))
	time := ctx.String("time")
	relTime := getRelTime(ctx)
	for _, src := range ctx.Args() {
		// Use the same revision number for each path.
		argPath, err := makeSimpleFSPathWithArchiveParams(
			src, rev, time, relTime)
		if err != nil {
			return err
		}
		pathType, err := argPath.PathType()
		if err != nil {
			return err
		}
		if pathType != keybase1.PathType_KBFS &&
			pathType != keybase1.PathType_KBFS_ARCHIVED {
			return errors.New("ls requires KBFS path arguments")
		}
		c.paths = append(c.paths, argPath)
	}

	return err
}
175638
func parseArguments() {
	// create flags parser in global var, for flagsParser.Active.Name (operation)
	flagsParser = goflags.NewParser(&flags, goflags.Default)

	// parse flags
	args, err := flagsParser.Parse()
	if err != nil {
		// assert the err to be a flags.Error
		flagError := err.(*goflags.Error)
		if flagError.Type == goflags.ErrHelp {
			// user asked for help on flags.
			// program can exit successfully
			os.Exit(0)
		}
		if flagError.Type == goflags.ErrUnknownFlag {
			fmt.Println("Use --help to view available options.")
			os.Exit(1)
		}
		if flagError.Type == goflags.ErrRequired {
			os.Exit(1)
		}
		fmt.Printf("Error parsing flags: %s\n", err)
		os.Exit(1)
	}

	// error on left-over arguments
	if len(args) > 0 {
		fmt.Printf("Unexpected arguments: %s\nUse --help to view available options.", args)
		os.Exit(1)
	}

	// default ImportPath to pwd when not set
	if len(flags.ImportPaths) == 0 {
		pwd, err := os.Getwd()
		if err != nil {
			fmt.Printf("error getting pwd: %s\n", err)
			os.Exit(1)
		}
		verbosef("using pwd as import path\n")
		// find non-absolute path for this pwd
		pkg, err := build.ImportDir(pwd, build.FindOnly)
		if err != nil {
			fmt.Printf("error using current directory as import path: %s\n", err)
			os.Exit(1)
		}
		flags.ImportPaths = append(flags.ImportPaths, pkg.ImportPath)
		verbosef("using import paths: %s\n", flags.ImportPaths)
		return
	}
}
221317
func parseArgsDataString(stdin io.Reader, args []string) (map[string]string, error) {
	raw, err := parseArgsData(stdin, args)
	if err != nil {
		return nil, err
	}

	var result map[string]string
	if err := mapstructure.WeakDecode(raw, &result); err != nil {
		return nil, errors.Wrap(err, "failed to convert values to strings")
	}
	if result == nil {
		result = make(map[string]string)
	}
	return result, nil
}
317443
func parseAlgorithms(algo string) (algorithms []string) {
	if algo == "" {
		algorithms = []string { "md5" }
	} else {
		algorithms = strings.Split(algo, ",")
	}
	return algorithms
}
539126
func (f *FlagSet) ParseEnv(environ []string) error {

	m := f.formal

	env := make(map[string]string)
	for _, s := range environ {
		i := strings.Index(s, "=")
		if i < 1 {
			continue
		}
		env[s[0:i]] = s[i+1 : len(s)]
	}

	for _, flag := range m {
		name := flag.Name
		_, set := f.actual[name]
		if set {
			continue
		}

		flag, alreadythere := m[name]
		if !alreadythere {
			if name == "help" || name == "h" { // special case for nice help message.
				f.usage()
				return ErrHelp
			}
			return f.failf("environment variable provided but not defined: %s", name)
		}

		envKey := strings.ToUpper(flag.Name)
		if f.envPrefix != "" {
			envKey = f.envPrefix + "_" + envKey
		}
		envKey = strings.Replace(envKey, "-", "_", -1)

		value, isSet := env[envKey]
		if !isSet {
			continue
		}

		hasValue := false
		if len(value) > 0 {
			hasValue = true
		}

		if fv, ok := flag.Value.(boolFlag); ok && fv.IsBoolFlag() { // special case: doesn't need an arg
			if hasValue {
				if err := fv.Set(value); err != nil {
					return f.failf("invalid boolean value %q for environment variable %s: %v", value, name, err)
				}
			} else {
				// flag without value is regarded a bool
				fv.Set("true")
			}
		} else {
			if err := flag.Value.Set(value); err != nil {
				return f.failf("invalid value %q for environment variable %s: %v", value, name, err)
			}
		}

		// update f.actual
		if f.actual == nil {
			f.actual = make(map[string]*Flag)
		}
		f.actual[name] = flag

	}
	return nil
}
824801
func (rei *RemoteErrInfo) ParseErrMsg() {
	if rei.ErrMsg != "" || rei.ErrNo == 0 {
		return
	}

	switch rei.ErrNo {
	case -1:
		rei.ErrMsg = "由于您分享了违反相关法律法规的文件，分享功能已被禁用，之前分享出去的文件不受影响。"
	case -2:
		rei.ErrMsg = "用户不存在,请刷新页面后重试"
	case -3:
		rei.ErrMsg = "文件不存在,请刷新页面后重试"
	case -4:
		rei.ErrMsg = "登录信息有误，请重新登录试试"
	case -5:
		rei.ErrMsg = "host_key和user_key无效"
	case -6:
		rei.ErrMsg = "请重新登录"
	case -7:
		rei.ErrMsg = "该分享已删除或已取消"
	case -8:
		rei.ErrMsg = "该分享已经过期"
	case -9:
		rei.ErrMsg = "文件不存在"
	case -10:
		rei.ErrMsg = "分享外链已经达到最大上限100000条，不能再次分享"
	case -11:
		rei.ErrMsg = "验证cookie无效"
	case -12:
		rei.ErrMsg = "访问密码错误"
	case -14:
		rei.ErrMsg = "对不起，短信分享每天限制20条，你今天已经分享完，请明天再来分享吧！"
	case -15:
		rei.ErrMsg = "对不起，邮件分享每天限制20封，你今天已经分享完，请明天再来分享吧！"
	case -16:
		rei.ErrMsg = "对不起，该文件已经限制分享！"
	case -17:
		rei.ErrMsg = "文件分享超过限制"
	case -19:
		rei.ErrMsg = "需要输入验证码"
	case -30:
		rei.ErrMsg = "文件已存在"
	case -31:
		rei.ErrMsg = "文件保存失败"
	case -33:
		rei.ErrMsg = "一次支持操作999个，减点试试吧"
	case -62:
		rei.ErrMsg = "可能需要输入验证码"
	case -70:
		rei.ErrMsg = "你分享的文件中包含病毒或疑似病毒，为了你和他人的数据安全，换个文件分享吧"
	case 2:
		rei.ErrMsg = "参数错误"
	case 3:
		rei.ErrMsg = "未登录或帐号无效"
	case 4:
		rei.ErrMsg = "存储好像出问题了，请稍候再试"
	case 108:
		rei.ErrMsg = "文件名有敏感词，优化一下吧"
	case 110:
		rei.ErrMsg = "分享次数超出限制，可以到“我的分享”中查看已分享的文件链接"
	case 112:
		rei.ErrMsg = "页面已过期，请刷新后重试"
	case 113:
		rei.ErrMsg = "签名错误"
	case 114:
		rei.ErrMsg = "当前任务不存在，保存失败"
	case 115:
		rei.ErrMsg = "该文件禁止分享"
	default:
		rei.ErrMsg = "未知错误"
	}
}
311491
func ParseEnv(env []string) (map[string]string, error) {
	m := make(map[string]string)

	for _, s := range env {
		parts := strings.SplitN(s, "=", 2)
		if len(parts) == 2 {
			m[parts[0]] = parts[1]
		} else {
			return nil, fmt.Errorf("environment variable %q is missing a value", parts[0])
		}
	}

	return m, nil
}
884726
func (opts *runOpts) goArgs() []string {
	a := []string{
		"test",
		"-json",
	}

	if opts.run != "" {
		a = append(a, "-run=TestE2E/"+opts.run)
	}

	a = append(a, []string{
		"github.com/hashicorp/nomad/e2e",
		"-env=" + opts.env,
		"-env.provider=" + opts.provider,
	}...)

	if opts.slow {
		a = append(a, "-slow")
	}

	if opts.local {
		a = append(a, "-local")
	}
	return a
}
1127200
func parseArgs(args []string, flagMap map[string]reflect.StructField, parsers map[reflect.Type]parse.Parser) (map[string]parse.Parser, error) {
	newParsers := map[string]parse.Parser{}
	flagSet := flag.NewFlagSet("flaeg.Load", flag.ContinueOnError)

	// Disable output
	flagSet.SetOutput(ioutil.Discard)

	var err error
	for flg, structField := range flagMap {
		if parser, ok := parsers[structField.Type]; ok {
			newParserValue := reflect.New(reflect.TypeOf(parser).Elem())
			newParserValue.Elem().Set(reflect.ValueOf(parser).Elem())
			newParser := newParserValue.Interface().(parse.Parser)

			if short := structField.Tag.Get("short"); len(short) == 1 {
				flagSet.VarP(newParser, flg, short, structField.Tag.Get("description"))
			} else {
				flagSet.Var(newParser, flg, structField.Tag.Get("description"))
			}
			newParsers[flg] = newParser
		} else {
			err = ErrParserNotFound
		}
	}

	// prevents case sensitivity issue
	args = argsToLower(args)
	if errParse := flagSet.Parse(args); errParse != nil {
		return nil, errParse
	}

	// Visitor in flag.Parse
	var flagList []*flag.Flag
	visitor := func(fl *flag.Flag) {
		flagList = append(flagList, fl)
	}

	// Fill flagList with parsed flags
	flagSet.Visit(visitor)

	// Return var
	valMap := make(map[string]parse.Parser)

	// Return parsers on parsed flag
	for _, flg := range flagList {
		valMap[flg.Name] = newParsers[flg.Name]
	}

	return valMap, err
}
302744
func DefaultPathEnv(os string) string {
	if runtime.GOOS == "windows" {
		if os != runtime.GOOS {
			return defaultUnixPathEnv
		}
		// Deliberately empty on Windows containers on Windows as the default path will be set by
		// the container. Docker has no context of what the default path should be.
		return ""
	}
	return defaultUnixPathEnv

}
676169
func ParseAndFail(v interface{}) {
	globalFlagSet = NewFlagSet(filepath.Base(os.Args[0]), v)
	globalFlagSet.ParseAndFail(os.Stderr, os.Args[1:])
}
237463
func (ctx *Context) Argv() interface{} {
	if ctx.argvList == nil || len(ctx.argvList) == 0 {
		return nil
	}
	return ctx.argvList[0]
}