diff options
| author | Eric Paris <[email protected]> | 2015-05-27 16:10:28 -0400 |
|---|---|---|
| committer | Eric Paris <[email protected]> | 2015-06-22 15:29:55 -0400 |
| commit | 469982769211123a1718ad9edf5d03bd39aed547 (patch) | |
| tree | e27225869f2771ded175b16e1ce51e8f9cdcbdf6 | |
| parent | b319e90e90fa3261384806182c8f147a4d16c46a (diff) | |
Add support for '--flag arg'
| -rw-r--r-- | flag.go | 4 | ||||
| -rw-r--r-- | flag_test.go | 2 |
2 files changed, 5 insertions, 1 deletions
@@ -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", |
