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

parsePath no err

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