@cryptotaxi247 / kubo / commits / 3255bb02d

commands/cli: Output command path in Parse

Matt Bell committed Nov 8, 2014 at 03:18 UTC 3255bb02d1b1835675a7710766e5af6059ceb921
1 file changed +6 -6
commands/cli/parse.go
+6 -6
@@ -11,7 +11,7 @@ import (
11
12 // Parse parses the input commandline string (cmd, flags, and args).
13 // returns the corresponding command Request object.
14 -func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command, *cmds.Command, error) {
14 +func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command, *cmds.Command, []string, error) {
15 var root, cmd *cmds.Command
16 var path, stringArgs []string
17 var opts map[string]interface{}
@@ -22,7 +22,7 @@ func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command,
22 p, i, c := parsePath(input, r)
23 o, s, err := parseOptions(i)
24 if err != nil {
25 - return nil, root, c, err
25 + return nil, root, c, p, err
26 }
27
28 length := len(p)
@@ -37,22 +37,22 @@ func Parse(input []string, roots ...*cmds.Command) (cmds.Request, *cmds.Command,
37 }
38
39 if maxLength == 0 {
40 - return nil, root, nil, errors.New("Not a valid subcommand")
40 + return nil, root, nil, path, errors.New("Not a valid subcommand")
41 }
42
43 args, err := parseArgs(stringArgs, cmd)
44 if err != nil {
45 - return nil, root, cmd, err
45 + return nil, root, cmd, path, err
46 }
47
48 req := cmds.NewRequest(path, opts, args, cmd)
49
50 err = cmd.CheckArguments(req)
51 if err != nil {
52 - return nil, root, cmd, err
52 + return req, root, cmd, path, err
53 }
54
55 - return req, root, cmd, nil
55 + return req, root, cmd, path, nil
56 }
57
58 // parsePath separates the command path and the opts and args from a command string