From 9afb85714a922af7c975087366e5c8f1759330d6 Mon Sep 17 00:00:00 2001
From: Matt Bell <mappum@gmail.com>
Date: Wed, 12 Nov 2014 20:52:16 -0800
Subject: [PATCH] commands/cli: Don't return root in Parse

---
 cmd/ipfs2/main.go     |  2 +-
 commands/cli/parse.go | 16 +++++++---------
 2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/cmd/ipfs2/main.go b/cmd/ipfs2/main.go
index 2ccef1645..0ef3ac69a 100644
--- a/cmd/ipfs2/main.go
+++ b/cmd/ipfs2/main.go
@@ -160,7 +160,7 @@ func (i *cmdInvocation) Run() (output io.Reader, err error) {
 func (i *cmdInvocation) Parse(args []string) error {
 	var err error
 
-	i.req, i.root, i.cmd, i.path, err = cmdsCli.Parse(args, Root)
+	i.req, i.cmd, i.path, err = cmdsCli.Parse(args, Root)
 	if err != nil {
 		return err
 	}
diff --git a/commands/cli/parse.go b/commands/cli/parse.go
index 8e1dba86f..3beb0e600 100644
--- a/commands/cli/parse.go
+++ b/commands/cli/parse.go
@@ -15,38 +15,36 @@ var ErrInvalidSubcmd = errors.New("subcommand not found")
 // Parse parses the input commandline string (cmd, flags, and args).
 // returns the corresponding command Request object.
 // Parse will search each root to find the one that best matches the requested subcommand.
-// TODO: get rid of extraneous return values (e.g. we ended up not needing the root value anymore)
-// TODO: get rid of multiple-root support, we should only need one now
-func Parse(input []string, root *cmds.Command) (cmds.Request, *cmds.Command, *cmds.Command, []string, error) {
+func Parse(input []string, root *cmds.Command) (cmds.Request, *cmds.Command, []string, error) {
 	// use the root that matches the longest path (most accurately matches request)
 	path, input, cmd := parsePath(input, root)
 	opts, stringArgs, err := parseOptions(input)
 	if err != nil {
-		return nil, root, cmd, path, err
+		return nil, cmd, path, err
 	}
 
 	if len(path) == 0 {
-		return nil, root, nil, path, ErrInvalidSubcmd
+		return nil, nil, path, ErrInvalidSubcmd
 	}
 
 	args, err := parseArgs(stringArgs, cmd)
 	if err != nil {
-		return nil, root, cmd, path, err
+		return nil, cmd, path, err
 	}
 
 	optDefs, err := root.GetOptions(path)
 	if err != nil {
-		return nil, root, cmd, path, err
+		return nil, cmd, path, err
 	}
 
 	req := cmds.NewRequest(path, opts, args, cmd, optDefs)
 
 	err = cmd.CheckArguments(req)
 	if err != nil {
-		return req, root, cmd, path, err
+		return req, cmd, path, err
 	}
 
-	return req, root, cmd, path, nil
+	return req, cmd, path, nil
 }
 
 // parsePath separates the command path and the opts and args from a command string
-- 
GitLab