@cryptotaxi247 / kubo / commits / 4986600e5

parsePath no err

Juan Batiz-Benet committed Oct 20, 2014 at 07:59 UTC 4986600e5455ce98f1cddf79da1915399c47e26a
2 files changed +4 -11
commands/cli/parse.go
+3 -7
@@ -10,11 +10,7 @@ import (
10 // Parse parses the input commandline string (cmd, flags, and args).
11 // returns the corresponding command Request object.
12 func Parse(input []string, root *commands.Command) (*commands.Request, error) {
13 - path, input, err := parsePath(input, root)
14 - if err != nil {
15 - return nil, err
16 - }
17 -
13 + path, input := parsePath(input, root)
14 opts, args, err := parseOptions(input)
15 if err != nil {
16 return nil, err
@@ -24,7 +20,7 @@ func Parse(input []string, root *commands.Command) (*commands.Request, error) {
20 }
21
22 // parsePath gets the command path from the command line input
27 -func parsePath(input []string, root *commands.Command) ([]string, []string, error) {
23 +func parsePath(input []string, root *commands.Command) ([]string, []string) {
24 cmd := root
25 i := 0
26
@@ -41,7 +37,7 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
37 i++
38 }
39
44 - return input[:i], input[i:], nil
40 + return input[:i], input[i:]
41 }
42
43 // parseOptions parses the raw string values of the given options
commands/cli/parse_test.go
+1 -4
@@ -35,10 +35,7 @@ func TestOptionParsing(t *testing.T) {
35 t.Error("Should have failed (duplicate option name)")
36 }
37
38 - path, args, err := parsePath([]string{"test", "beep", "boop"}, cmd)
39 - if err != nil {
40 - t.Error("Should have passed")
41 - }
38 + path, args := parsePath([]string{"test", "beep", "boop"}, cmd)
39 if len(path) != 1 || path[0] != "test" {
40 t.Error("Returned path was defferent than expected: %v", path)
41 }