aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--flag.go4
-rw-r--r--flag_test.go2
2 files changed, 5 insertions, 1 deletions
diff --git a/flag.go b/flag.go
index 55c381c..865259b 100644
--- a/flag.go
+++ b/flag.go
@@ -585,6 +585,10 @@ func (f *FlagSet) parseLongArg(s string, args []string) (a []string, err error)
} else if len(flag.NoOptDefVal) > 0 {
// '--flag' (arg was optional)
value = flag.NoOptDefVal
+ } else if len(a) > 0 {
+ // '--flag arg'
+ value = a[0]
+ a = a[1:]
} else {
// '--flag' (arg was required)
err = f.failf("flag needs an argument: %s", s)
diff --git a/flag_test.go b/flag_test.go
index 67a6a27..a5928e5 100644
--- a/flag_test.go
+++ b/flag_test.go
@@ -176,7 +176,7 @@ func testParse(f *FlagSet, t *testing.T) {
"--int8=-8",
"--int32=-32",
"--int64=0x23",
- "--uint=24",
+ "--uint", "24",
"--uint8=8",
"--uint16=16",
"--uint32=32",