diff --git a/clop_version_about_test.go b/clop_version_about_test.go index 6aae097..970b875 100644 --- a/clop_version_about_test.go +++ b/clop_version_about_test.go @@ -10,7 +10,7 @@ import ( ) // 测试显示信息, 普通命令 -func Test_Version_Show2(t *testing.T) { +func Test_Version_Show(t *testing.T) { type show struct { Max int `clop:"short;long" usage:"max threads"` } @@ -19,20 +19,10 @@ func Test_Version_Show2(t *testing.T) { cmd := New([]string{"-h"}).SetProcName("Test_Version_Show").SetVersion("v0.0.2").SetExit(false).SetOutput(&buf) cmd.MustBind(&show{}) - assert.NotEqual(t, strings.Index(buf.String(), "v0.0.2"), -1) assert.NotEqual(t, strings.Index(buf.String(), "print version information"), -1) assert.NotEqual(t, strings.Index(buf.String(), "print the help information"), -1) } -// 测试显示信息 -func Test_Version_Show(t *testing.T) { - var buf bytes.Buffer - cmd := New([]string{"-h"}).SetProcName("Test_Version_Show").SetVersion("v0.0.2").SetExit(false).SetOutput(&buf) - cmd.MustBind(&git{}) - - assert.NotEqual(t, strings.Index(buf.String(), "v0.0.2"), -1) -} - // 测试about信息 func Test_About_Show(t *testing.T) { diff --git a/help_tmpl.go b/help_tmpl.go index 9d41d99..87b4acf 100644 --- a/help_tmpl.go +++ b/help_tmpl.go @@ -61,18 +61,11 @@ func (h *Help) output(w io.Writer) error { return tmpl.Execute(w, *h) } -var usageDefaultTmpl = ` -{{- $ShowUsageDefault := .ShowUsageDefault}} -{{- if gt (len .Version) 0}} - {{- .ProcessName}} {{.Version}} -{{end}} +var usageDefaultTmpl = `{{- $ShowUsageDefault := .ShowUsageDefault}}{{- if gt (len .About) 0}} +{{- .About}} -{{- if gt (len .About) 0}} - {{- .About}} {{end}} - -{{- if or (gt (len .Flags) 0) (gt (len .Options) 0) (gt (len .Args) 0) (gt (len .Subcommand) 0)}} -Usage: +{{- if or (gt (len .Flags) 0) (gt (len .Options) 0) (gt (len .Args) 0) (gt (len .Subcommand) 0)}}Usage: {{if gt (len .ProcessName) 0}}{{.ProcessName}} {{end}} {{- if gt (len .Flags) 0}}[Flags] {{end}} {{- if gt (len .Options) 0}}[Options] {{end}}