Commit a94d133
Changed files (1)
command.go
@@ -29,18 +29,12 @@ var commandArray = []Command{Command{Command: "exit",
return nil
}},
Command{Command: "test",
- Usage: "test [flags]",
+ Usage: "test [flags] [n]",
Flags: map[string]Flag{"blueprint": Flag{
Flag: "blueprint",
Usage: "--blueprint",
Description: "Allows to define a list of categories to use",
- Value: "false"},
- "questions": Flag{
- Flag: "questions",
- Usage: "--questions [n]",
- HasArgs: true,
- Description: "Specify the number of questions to pull. Default is 20.",
- Value: ""}},
+ Value: "false"}},
Description: "Execute a test. Given a number, will go through a test with [n] questions." +
" Type 'exit' to stop test.",
Run: executeTest},
@@ -200,12 +194,11 @@ func parseTestCommandFlags(command Command) (int, bool, error) {
if commandFlag.Value != "false" {
useBlueprint = true
}
- case "questions":
- if commandFlag.Value != "" {
- questions, err = strconv.Atoi(commandFlag.Value)
- }
}
}
+ if len(command.PositionalParameters) > 0 {
+ questions, err = strconv.Atoi(command.PositionalParameters[0])
+ }
return questions, useBlueprint, err
}
@@ -214,10 +207,7 @@ func parseTestCommandFlags(command Command) (int, bool, error) {
func executeTest(command Command) error {
client := &http.Client{}
var clientTest ClientTest
- var err error
- questions := 20
- useBluprint := false
- questions, useBluprint, err = parseTestCommandFlags(command)
+ questions, useBluprint, err := parseTestCommandFlags(command)
if err != nil {
return fmt.Errorf("Error while parsing flags for test: %+v", err)
}