diff options
-rw-r--r-- | lib/pure/parseopt.nim | 2 | ||||
-rw-r--r-- | tests/system/params.nim | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/pure/parseopt.nim b/lib/pure/parseopt.nim index 81a1fd1f0..5e79d8a18 100644 --- a/lib/pure/parseopt.nim +++ b/lib/pure/parseopt.nim @@ -71,7 +71,7 @@ when not defined(createNimRtl): proc next*(p: var TOptParser) {.rtl, extern: "npo$1".} proc nextOption(p: var TOptParser, token: string, allowEmpty: bool) = - for splitchar in ['=', ':']: + for splitchar in [':', '=']: if splitchar in token: let pos = token.find(splitchar) p.key = token[0..pos-1] diff --git a/tests/system/params.nim b/tests/system/params.nim index 1e8385dc8..0ea099daa 100644 --- a/tests/system/params.nim +++ b/tests/system/params.nim @@ -7,11 +7,12 @@ let argv = commandLineParams() if argv == @[]: # this won't work with spaces - assert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar --ab -c --a[baz]:doo") == 0 + assert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0 else: let f = toSeq(getopt()) echo f.repr assert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == "" - assert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar" - assert f[2].kind == cmdLongOption and f[2].key == "ab" and f[2].val == "" - assert f[3].kind == cmdShortOption and f[3].key == "c" and f[3].val == "" + assert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a" + assert f[2].kind == cmdLongOption and f[2].key == "a=c" and f[2].val == "d" + assert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == "" + assert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == "" |