diff options
author | Michał Zieliński <michal@zielinscy.org.pl> | 2013-12-09 22:22:06 +0100 |
---|---|---|
committer | Michał Zieliński <michal@zielinscy.org.pl> | 2013-12-09 23:29:16 +0100 |
commit | d1f3512aba83814146583538c46b7f0c84175423 (patch) | |
tree | 3425909ffab4a4fa5fc2d1f6c7130c65465296ae /tests | |
parent | 8dae66415966e2cba50fd5295c514a97ff187fc2 (diff) | |
download | Nim-d1f3512aba83814146583538c46b7f0c84175423.tar.gz |
Reimplement parseopt which parses arguments given as a sequence of strings, not single string.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/system/params.nim | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/system/params.nim b/tests/system/params.nim new file mode 100644 index 000000000..1e8385dc8 --- /dev/null +++ b/tests/system/params.nim @@ -0,0 +1,17 @@ +import os +import osproc +import parseopt +import sequtils + +let argv = commandLineParams() + +if argv == @[]: + # this won't work with spaces + assert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar --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 == "" |