Commit 66b0727d authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands/cli: Renamed parse functions to parse*

parent 1b356158
...@@ -8,12 +8,12 @@ import ( ...@@ -8,12 +8,12 @@ import (
) )
func Parse(input []string, root *commands.Command) ([]string, []string, map[string]string, error) { func Parse(input []string, root *commands.Command) ([]string, []string, map[string]string, error) {
opts, input, err := options(input, root) opts, input, err := parseOptions(input, root)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
path, args, err := path(input, root) path, args, err := parsePath(input, root)
if err != nil { if err != nil {
return nil, nil, nil, err return nil, nil, nil, err
} }
...@@ -23,7 +23,7 @@ func Parse(input []string, root *commands.Command) ([]string, []string, map[stri ...@@ -23,7 +23,7 @@ func Parse(input []string, root *commands.Command) ([]string, []string, map[stri
// options parses the raw string values of the given options // options parses the raw string values of the given options
// returns the parsed options as strings, along with the CLI input minus option blobs // returns the parsed options as strings, along with the CLI input minus option blobs
func options(input []string, root *commands.Command) (map[string]string, []string, error) { func parseOptions(input []string, root *commands.Command) (map[string]string, []string, error) {
opts := make(map[string]string) opts := make(map[string]string)
cleanInput := make([]string, 0) cleanInput := make([]string, 0)
...@@ -97,7 +97,7 @@ func options(input []string, root *commands.Command) (map[string]string, []strin ...@@ -97,7 +97,7 @@ func options(input []string, root *commands.Command) (map[string]string, []strin
} }
// path takes the command line (without options) and splits it into the command path and arguments // path takes the command line (without options) and splits it into the command path and arguments
func path(input []string, root *commands.Command) ([]string, []string, error) { func parsePath(input []string, root *commands.Command) ([]string, []string, error) {
cmd := root cmd := root
i := 0 i := 0
......
...@@ -8,7 +8,7 @@ import ( ...@@ -8,7 +8,7 @@ import (
) )
func TestOptionParsing(t *testing.T) { func TestOptionParsing(t *testing.T) {
opts, input, err := options([]string{ "test", "--beep", "--boop=\"5", "lol\"", "test2", "-cV" }, nil) opts, input, err := parseOptions([]string{ "test", "--beep", "--boop=\"5", "lol\"", "test2", "-cV" }, nil)
/*for k, v := range opts { /*for k, v := range opts {
fmt.Printf("%s: %s\n", k, v) fmt.Printf("%s: %s\n", k, v)
} }
...@@ -25,7 +25,7 @@ func TestOptionParsing(t *testing.T) { ...@@ -25,7 +25,7 @@ func TestOptionParsing(t *testing.T) {
cmd := &commands.Command{} cmd := &commands.Command{}
cmd.Register("test", &commands.Command{}) cmd.Register("test", &commands.Command{})
path, args, err := path([]string{ "test", "beep", "boop" }, cmd) path, args, err := parsePath([]string{ "test", "beep", "boop" }, cmd)
if err != nil { if err != nil {
t.Error("Should have passed") t.Error("Should have passed")
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment