@cryptotaxi247 / kubo / commits / 66b0727de

commands/cli: Renamed parse functions to parse*

Matt Bell committed Oct 14, 2014 at 14:29 UTC 66b0727de61ca7ee5ff64fe13e8c3df5c41ef93f
2 files changed +6 -6
commands/cli/parse.go
+4 -4
@@ -8,12 +8,12 @@ import (
8 )
9
10 func Parse(input []string, root *commands.Command) ([]string, []string, map[string]string, error) {
11 - opts, input, err := options(input, root)
11 + opts, input, err := parseOptions(input, root)
12 if err != nil {
13 return nil, nil, nil, err
14 }
15
16 - path, args, err := path(input, root)
16 + path, args, err := parsePath(input, root)
17 if err != nil {
18 return nil, nil, nil, err
19 }
@@ -23,7 +23,7 @@ func Parse(input []string, root *commands.Command) ([]string, []string, map[stri
23
24 // options parses the raw string values of the given options
25 // returns the parsed options as strings, along with the CLI input minus option blobs
26 -func options(input []string, root *commands.Command) (map[string]string, []string, error) {
26 +func parseOptions(input []string, root *commands.Command) (map[string]string, []string, error) {
27 opts := make(map[string]string)
28 cleanInput := make([]string, 0)
29
@@ -97,7 +97,7 @@ func options(input []string, root *commands.Command) (map[string]string, []strin
97 }
98
99 // path takes the command line (without options) and splits it into the command path and arguments
100 -func path(input []string, root *commands.Command) ([]string, []string, error) {
100 +func parsePath(input []string, root *commands.Command) ([]string, []string, error) {
101 cmd := root
102 i := 0
103
commands/cli/parse_test.go
+2 -2
@@ -8,7 +8,7 @@ import (
8 )
9
10 func TestOptionParsing(t *testing.T) {
11 - opts, input, err := options([]string{ "test", "--beep", "--boop=\"5", "lol\"", "test2", "-cV" }, nil)
11 + opts, input, err := parseOptions([]string{ "test", "--beep", "--boop=\"5", "lol\"", "test2", "-cV" }, nil)
12 /*for k, v := range opts {
13 fmt.Printf("%s: %s\n", k, v)
14 }
@@ -25,7 +25,7 @@ func TestOptionParsing(t *testing.T) {
25
26 cmd := &commands.Command{}
27 cmd.Register("test", &commands.Command{})
28 - path, args, err := path([]string{ "test", "beep", "boop" }, cmd)
28 + path, args, err := parsePath([]string{ "test", "beep", "boop" }, cmd)
29 if err != nil {
30 t.Error("Should have passed")
31 }