Skip to content

Commit

Permalink
更新版本信息显示功能,去除进程名显示 (#91)
Browse files Browse the repository at this point in the history
* 优化usage显示信息

* 更新版本信息显示功能,去除进程名显示

* 更新测试用例
  • Loading branch information
Greyh4t authored May 5, 2022
1 parent 03d9af3 commit b425ece
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion clop.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions clop_version_about_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit b425ece

Please sign in to comment.