Commit 3cde72f

Richard Luby <richluby@gmail.com>
2016-11-03 16:36:56
improved help commands
help now displays in more visually appealing manner. help also allows to specifiy a specific command on which to receive help
1 parent 4ab6ce2
Changed files (1)
command.go
@@ -48,14 +48,16 @@ var commandArray = []Command{
 			return nil
 		}},
 	Command{Command: "test",
-		Usage:       "test [number]",
-		Description: "Execute a test. Given a number, will go through a test with [n] questions. Type 'exit' to stop test.",
-		Run:         executeTest},
+		Usage: "test [--blueprint] [number]",
+		Description: "Execute a test. Given a number, will go through a test with [n] questions." +
+			" If " + COLOR_GREEN + "--blueprint" + COLOR_RESET + " is specified, test will be generated according to the test generation" +
+			" outline specified. Type 'exit' to stop test.",
+		Run: executeTest},
 	Command{
 		Command: "user",
 		Usage:   "user <username> <token>",
 		Description: "Set the user name to utilize during this session. If not set, anonymous will be used." +
-			"'token' is a unique, non-secret key to prevent duplicate users from occurring.",
+			COLOR_GREEN + " token" + COLOR_RESET + " is a unique, non-secret key to prevent duplicate users from occurring.",
 		Run: func(args []string) error {
 			if len(args) < 1 {
 				return fmt.Errorf("Could not set the user due to empty username.")
@@ -69,13 +71,18 @@ var commandArray = []Command{
 // helpCommand prints the help for the list of available commands.
 // it cannot exist in the initialization due to initialization loops
 var helpCommand = Command{Command: "help",
-	Description: "Display help for all known commands.",
+	Usage: "help [command]",
+	Description: "Display help for all known commands. If " + COLOR_GREEN + "command" + COLOR_RESET + " is specified, " +
+		"displays help for that command.",
 	Run: func(args []string) error {
 		for _, command := range commandArray {
+			if len(args) > 0 && args[0] != command.Command { // only print help for desired command
+				continue
+			}
 			if strings.Compare(command.Usage, "") == 0 {
-				fmt.Printf("%s\n\t%s\n", command.Command, command.Description)
+				fmt.Printf("> %s\n\t%s\n", COLOR_GREEN+command.Command+COLOR_RESET, command.Description)
 			} else {
-				fmt.Printf("%s\n\t%s\n", command.Usage, command.Description)
+				fmt.Printf("> %s\n\t%s\n", COLOR_GREEN+command.Usage+COLOR_RESET, command.Description)
 			}
 		}
 		return nil