From b425ece04cbda206c2bc5acffd7703fd1cae7bca Mon Sep 17 00:00:00 2001 From: Greyh4t Date: Thu, 5 May 2022 20:14:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E7=89=88=E6=9C=AC=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD=EF=BC=8C=E5=8E=BB?= =?UTF-8?q?=E9=99=A4=E8=BF=9B=E7=A8=8B=E5=90=8D=E6=98=BE=E7=A4=BA=20(#91)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 优化usage显示信息 * 更新版本信息显示功能,去除进程名显示 * 更新测试用例 --- clop.go | 2 +- clop_version_about_test.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/clop.go b/clop.go index add19e3..74d459c 100644 --- a/clop.go +++ b/clop.go @@ -650,7 +650,7 @@ func (c *Clop) genHelpMessage(h *Help) { // 显示version信息 func (c *Clop) showVersion() { - fmt.Fprintf(c.w, "%s %s\n", c.procName, c.version) + fmt.Fprint(c.w, c.version) if c.exit { os.Exit(0) } diff --git a/clop_version_about_test.go b/clop_version_about_test.go index 60b2daa..6aae097 100644 --- a/clop_version_about_test.go +++ b/clop_version_about_test.go @@ -51,7 +51,7 @@ func Test_Version_Option_Short(t *testing.T) { cmd := New([]string{"-V"}).SetProcName(procName).SetVersion(version).SetExit(false).SetOutput(&buf) cmd.MustBind(&git{}) - assert.NotEqual(t, strings.Index(buf.String(), fmt.Sprintf("%s %s\n", procName, version)), -1) + assert.NotEqual(t, strings.Index(buf.String(), version), -1) } // 测试 --version @@ -62,7 +62,7 @@ func Test_Version_Option_Long(t *testing.T) { cmd := New([]string{"--version"}).SetProcName(procName).SetVersion(version).SetExit(false).SetOutput(&buf) cmd.MustBind(&git{}) - assert.NotEqual(t, strings.Index(buf.String(), fmt.Sprintf("%s %s\n", procName, version)), -1) + assert.NotEqual(t, strings.Index(buf.String(), version), -1) } // 测试-V