more commands and help

This commit is contained in:
Radu Ioan Fericean
2014-04-18 23:03:51 +03:00
parent 6df17bf2e8
commit bcb9582d6b
20 changed files with 924 additions and 2 deletions

View File

@@ -44,6 +44,30 @@ var (
)
func executeCommand(command string) {
if strings.TrimSpace(command) == "help" {
commands := console.GetCommands()
fmt.Println("Commands:")
for name, cmd := range commands {
fmt.Print(name, cmd.Usage())
}
return
}
if strings.HasPrefix(command, "help") {
words := strings.Split(command, " ")
if len(words) > 1 {
commands := console.GetCommands()
if cmd, ok := commands[words[1]]; ok {
fmt.Print(cmd.Usage())
} else {
fmt.Print("Available commands: ")
for name, _ := range commands {
fmt.Print(name + " ")
}
fmt.Println()
}
return
}
}
cmd, cmdErr := console.GetCommandValue(command, *verbose)
if cmdErr != nil {
fmt.Println(cmdErr)