// Parses given arguments, returning any error.
975691
func ParseErr(cmd interface{}, args []string, opts ...parseOpt) (err error) {
	p, err := newParser(cmd, opts...)
	if err != nil {
		return
	}
	return p.parse(args)
}
358059
func (c *Command) Parse(params []CommandInfoParam) ([]internal.ReflectManagedMethodExecuterSoapArgument, error) {
	flags := flag.NewFlagSet(strings.Join(c.name, " "), flag.ExitOnError)
	vals := make([]string, len(params))

	for i, p := range params {
		v := &vals[i]
		for _, a := range p.Aliases {
			a = strings.TrimPrefix(a[1:], "-")
			flags.StringVar(v, a, "", p.Help)
		}
	}

	err := flags.Parse(c.args)
	if err != nil {
		return nil, err
	}

	args := []internal.ReflectManagedMethodExecuterSoapArgument{}

	for i, p := range params {
		if vals[i] == "" {
			continue
		}
		args = append(args, c.Argument(p.Name, vals[i]))
	}

	return args, nil
}
926318
func (parser IntTypeParser) Parse(d DataType) error {
	if value, ok := AsInt(d); ok {
		parser.setter(value)
	} else {
		return fmt.Errorf("Error parsing type of %#v as an Integer", d)
	}
	return nil
}
673769
func Parse(s string) (r T, err error) {
	_, err = fmt.Sscan(s,
		&r[0][0], &r[0][1], &r[0][2],
		&r[1][0], &r[1][1], &r[1][2],
		&r[2][0], &r[2][1], &r[2][2],
	)
	return r, err
}
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
}
589757
func (c *Context) Args() Args {
	args := Args(c.flagSet.Args())
	return args
}
72832
func Error(format string, args ...interface{}) {
	if len(args) == 0 {
		fmt.Fprintln(ErrorWriter, format)
		return
	}
	fmt.Fprintf(ErrorWriter, format+"\n", args...)
}
705656
func (m *MultiError) Error() string {
	var s string
	var n int
	for _, err := range *m {
		if err != nil {
			if n == 0 {
				s = err.Error()
			}
			n++
		}
	}
	switch n {
	case 0:
		return ""
	case 1:
		return s
	case 2:
		return s + " and 1 other error"
	}
	return fmt.Sprintf("%s (and %d other errors)", s, n-1)
}
1248231
func (*GoFlags) Parse(usage func()) []string {
	flag.Usage = usage
	flag.Parse()
	args := flag.Args()
	if len(args) == 0 {
		usage()
	}
	return args
}
10348
func (parser StringTypeParser) Parse(d DataType) error {
	if value, ok := AsString(d); ok {
		parser.setter(value)
	} else {
		return fmt.Errorf("Error parsing type of %#v as a String", d)
	}
	return nil
}
1126853
func (p *ListParam) Args() []string {
	if len(p.values) == 0 {
		return []string{}
	}
	out := make([]string, 0, len(p.values))
	for _, v := range p.values {
		out = append(out, v.Args()...)
	}
	return out
}
837730
func (e *ParseError) Error() string {
	if e.Message != "" {
		return fmt.Sprintf("%s at line %d, char %d", e.Message, e.Pos.Line+1, e.Pos.Char+1)
	}
	return fmt.Sprintf("found %s, expected %s at line %d, char %d", e.Found, strings.Join(e.Expected, ", "), e.Pos.Line+1, e.Pos.Char+1)
}
339959
func ParamParseError(in string, f reflect.StructField, expected string) error {
	return fmt.Errorf("%s: %s value must be %s", f.Name, in, expected)
}
1083139
func (p FloatParser) Parse(field string) (result interface{}, err error) {
	return strconv.ParseFloat(field, 64)
}
894249
func simplifyArgs(args []string) (r []string) {
	r = make([]string, 0, len(args)*2)
	for i, arg := range args {
		if arg == "--" {
			for j := i; j < len(args); j++ {
				r = append(r, args[j])
			}
			break
		}
		if len(arg) > 2 && arg[0] == '-' && arg[1] != '-' {
			for j := 1; j < len(arg); j++ {
				r = append(r, "-"+string(arg[j]))
			}
		} else {
			r = append(r, arg)
		}
	}
	return
}
1303413
func (al *Apps) GetArgs() [][]string {
	var aal [][]string
	for _, a := range al.apps {
		aal = append(aal, a.Args)
	}
	return aal
}
928956
func Parse(args []string, argv interface{}) error {
	clr := color.Color{}
	fset := parseArgv(args, argv, clr)
	return fset.err
}