From 46f517e1c6a47c92eddc21af8118cf81f9f69ea6 Mon Sep 17 00:00:00 2001 From: name5566 Date: Fri, 14 Aug 2015 15:40:15 +0800 Subject: [PATCH] add quit command --- console/command.go | 12 +++++------- console/console.go | 3 +++ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/console/command.go b/console/command.go index 8a898b88..52193803 100644 --- a/console/command.go +++ b/console/command.go @@ -84,17 +84,15 @@ func (c *CommandHelp) name() string { } func (c *CommandHelp) help() string { - return "This help text" + return "this help text" } func (c *CommandHelp) run([]string) string { output := "Commands:\r\n" - for i, c := range commands { - output += c.name() + " - " + c.help() - if i < len(commands)-1 { - output += "\r\n" - } + for _, c := range commands { + output += c.name() + " - " + c.help() + "\r\n" } + output += "quit - exit console" return output } @@ -164,7 +162,7 @@ func (c *CommandProf) name() string { } func (c *CommandProf) help() string { - return "Writes a pprof-formatted snapshot" + return "writes a pprof-formatted snapshot" } func (c *CommandProf) usage() string { diff --git a/console/console.go b/console/console.go index dad07c54..402db198 100644 --- a/console/console.go +++ b/console/console.go @@ -59,6 +59,9 @@ func (a *Agent) Run() { if len(args) == 0 { continue } + if args[0] == "quit" { + break + } var c Command for _, _c := range commands { if _c.name() == args[0] {