Commit 4986600e authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

parsePath no err

parent 92528ba7
......@@ -10,11 +10,7 @@ import (
// Parse parses the input commandline string (cmd, flags, and args).
// returns the corresponding command Request object.
func Parse(input []string, root *commands.Command) (*commands.Request, error) {
path, input, err := parsePath(input, root)
if err != nil {
return nil, err
}
path, input := parsePath(input, root)
opts, args, err := parseOptions(input)
if err != nil {
return nil, err
......@@ -24,7 +20,7 @@ func Parse(input []string, root *commands.Command) (*commands.Request, error) {
}
// parsePath gets the command path from the command line input
func parsePath(input []string, root *commands.Command) ([]string, []string, error) {
func parsePath(input []string, root *commands.Command) ([]string, []string) {
cmd := root
i := 0
......@@ -41,7 +37,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
i++
}
return input[:i], input[i:], nil
return input[:i], input[i:]
}
// parseOptions parses the raw string values of the given options
......
......@@ -35,10 +35,7 @@ func TestOptionParsing(t *testing.T) {
t.Error("Should have failed (duplicate option name)")
}
path, args, err := parsePath([]string{"test", "beep", "boop"}, cmd)
if err != nil {
t.Error("Should have passed")
}
path, args := parsePath([]string{"test", "beep", "boop"}, cmd)
if len(path) != 1 || path[0] != "test" {
t.Error("Returned path was defferent than expected: %v", path)
}
......
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