@cryptotaxi247 / kubo / commits / 968ec344e

commands/cli: Made Parse return a Request object instead of separate values

Matt Bell committed Oct 15, 2014 at 16:36 UTC 968ec344e55b9c6fad857e969095c74e4bab463f
1 file changed +7 -7
commands/cli/parse.go
+7 -7
@@ -7,23 +7,23 @@ import (
7 "github.com/jbenet/go-ipfs/commands"
8 )
9
10 -func Parse(input []string, root *commands.Command) ([]string, []string, map[string]string, error) {
10 +func Parse(input []string, root *commands.Command) (*commands.Request, error) {
11 path, input, err := parsePath(input, root)
12 if err != nil {
13 - return nil, nil, nil, err
13 + return nil, err
14 }
15
16 options, err := root.GetOptions(path)
17 if err != nil {
18 - return nil, nil, nil, err
18 + return nil, err
19 }
20
21 opts, args, err := parseOptions(input, options)
22 if err != nil {
23 - return nil, nil, nil, err
23 + return nil, err
24 }
25
26 - return path, args, opts, nil
26 + return commands.NewRequest(path, opts, args), nil
27 }
28
29 // parsePath gets the command path from the command line input
@@ -49,8 +49,8 @@ func parsePath(input []string, root *commands.Command) ([]string, []string, erro
49
50 // parseOptions parses the raw string values of the given options
51 // returns the parsed options as strings, along with the CLI args
52 -func parseOptions(input []string, options map[string]commands.Option) (map[string]string, []string, error) {
53 - opts := make(map[string]string)
52 +func parseOptions(input []string, options map[string]commands.Option) (map[string]interface{}, []string, error) {
53 + opts := make(map[string]interface{})
54 args := make([]string, 0)
55
56 // TODO: error if one option is defined multiple times