Update help printer

This commit is contained in:
Asim
2016-01-01 02:45:15 +00:00
parent 9e7e8742b4
commit 59a667130c
3 changed files with 28 additions and 1 deletions

View File

@@ -3,6 +3,7 @@ package cmd
import (
"flag"
"fmt"
"io"
"math/rand"
"os"
"strings"
@@ -160,6 +161,11 @@ var (
func init() {
rand.Seed(time.Now().Unix())
help := cli.HelpPrinter
cli.HelpPrinter = func(writer io.Writer, templ string, data interface{}) {
help(writer, templ, data)
os.Exit(0)
}
}
func newCmd(opts ...Option) Cmd {
@@ -174,6 +180,10 @@ func newCmd(opts ...Option) Cmd {
o(&options)
}
if len(options.Description) == 0 {
options.Description = "a go-micro service"
}
cmd := new(cmd)
cmd.opts = options
cmd.app = cli.NewApp()
@@ -183,6 +193,11 @@ func newCmd(opts ...Option) Cmd {
cmd.app.Before = cmd.Before
cmd.app.Flags = DefaultFlags
cmd.app.Action = func(c *cli.Context) {}
if len(options.Version) == 0 {
cmd.app.HideVersion = true
}
return cmd
}