From 39583856c0ed76e46d51627e43e22d0024943b6e Mon Sep 17 00:00:00 2001 From: spf13 Date: Sat, 28 Sep 2013 22:42:30 -0400 Subject: [PATCH] fix trailing on help output --- command.go | 9 +++++++++ commander.go | 5 ++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/command.go b/command.go index 34f3120..e15476a 100644 --- a/command.go +++ b/command.go @@ -176,6 +176,15 @@ func (c *Command) Usage() error { return err } +func (c *Command) UsageString() string { + tmpOutput := c.Commander().cmdr.output + bb := new(bytes.Buffer) + c.Commander().SetOutput(bb) + c.Usage() + c.Commander().cmdr.output = tmpOutput + return bb.String() +} + // The full path to this command func (c *Command) CommandPath() string { str := c.Name() diff --git a/commander.go b/commander.go index e1dae1b..411e74e 100644 --- a/commander.go +++ b/commander.go @@ -143,8 +143,7 @@ Additional help topics: {{if gt .Commands 0 }}{{range .Commands}}{{if not .Runna Use "{{.Commander.Name}} help [command]" for more information about that command. ` - c.HelpTemplate = `{{.Name}} -{{.Long | trim}} -{{if .Runnable}}{{.Usage}}{{end}} + c.HelpTemplate = `{{.Long | trim}} +{{if .Runnable}}{{.UsageString}}{{end}} ` }