提交 915f68dd 编写于 作者: J Jingwen Owen Ou

Merge pull request #661 from github/version_help_flags

Delegate `git —-version` and `git —-help` to Hub
......@@ -173,6 +173,8 @@ func slurpGlobalFlags(args []string) (aa []string, noop bool) {
if arg == "--noop" {
noop = true
aa, _ = removeItem(args, i)
} else if arg == "--version" || arg == "--help" {
aa[i] = strings.TrimPrefix(arg, "--")
}
}
......
......@@ -23,6 +23,14 @@ func TestNewArgs(t *testing.T) {
assert.Equal(t, "command", args.Command)
assert.Equal(t, 1, args.ParamsSize())
assert.T(t, args.Noop)
args = NewArgs([]string{"--version"})
assert.Equal(t, "version", args.Command)
assert.Equal(t, 0, args.ParamsSize())
args = NewArgs([]string{"--help"})
assert.Equal(t, "help", args.Command)
assert.Equal(t, 0, args.ParamsSize())
}
func TestArgs_Words(t *testing.T) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册