From 158410a180e6ae26e01e2c53bc7333b776c7985f Mon Sep 17 00:00:00 2001 From: Owen Ou Date: Wed, 22 Oct 2014 14:02:11 -0700 Subject: [PATCH] =?UTF-8?q?Delegate=20`git=20=E2=80=94-version`=20and=20`g?= =?UTF-8?q?it=20=E2=80=94-help`=20to=20Hub?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- commands/args.go | 2 ++ commands/args_test.go | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/commands/args.go b/commands/args.go index 87771240..e71e072b 100644 --- a/commands/args.go +++ b/commands/args.go @@ -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, "--") } } diff --git a/commands/args_test.go b/commands/args_test.go index 447b18e3..d72fca52 100644 --- a/commands/args_test.go +++ b/commands/args_test.go @@ -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) {