Commit 66e6da3d authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/cli: Added value parsing for single-dash options

parent 08885c0c
...@@ -46,7 +46,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro ...@@ -46,7 +46,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
// options parses the raw string values of the given options // options parses the raw string values of the given options
// returns the parsed options as strings, along with the CLI args // returns the parsed options as strings, along with the CLI args
func parseOptions(input, path []string, root *commands.Command) (map[string]string, []string, error) { func parseOptions(input, path []string, root *commands.Command) (map[string]string, []string, error) {
_, err := root.GetOptions(path) options, err := root.GetOptions(path)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
...@@ -109,11 +109,21 @@ func parseOptions(input, path []string, root *commands.Command) (map[string]stri ...@@ -109,11 +109,21 @@ func parseOptions(input, path []string, root *commands.Command) (map[string]stri
return nil, nil, fmt.Errorf("Invalid option blob: '%s'", input[i]) return nil, nil, fmt.Errorf("Invalid option blob: '%s'", input[i])
} }
nameS := ""
for _, name := range blob { for _, name := range blob {
opts[string(name)] = "" nameS = string(name)
opts[nameS] = ""
} }
// TODO: interpret next blob as value if the last option isn't a bool if nameS != "" {
opt, ok := options[nameS]
if ok && opt.Type != commands.Bool {
i++
if i <= len(input) {
opts[nameS] = input[i]
}
}
}
} else { } else {
args = append(args, blob) args = append(args, blob)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment