File: tparams.nim

package info (click to toggle)
nim 2.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,911,644 kB
  • sloc: sh: 24,603; ansic: 1,761; python: 1,492; makefile: 1,013; sql: 298; asm: 141; xml: 13
file content (22 lines) | stat: -rw-r--r-- 764 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
discard """
joinable: false
"""

# not joinable because it executes itself with parameters
import os
import osproc
import parseopt
import sequtils

let argv = commandLineParams()

if argv == @[]:
  # this won't work with spaces
  doAssert execShellCmd(getAppFilename() & " \"foo bar\" --aa:bar=a --a=c:d --ab -c --a[baz]:doo") == 0
else:
  let f = toSeq(getopt())
  doAssert f[0].kind == cmdArgument and f[0].key == "foo bar" and f[0].val == ""
  doAssert f[1].kind == cmdLongOption and f[1].key == "aa" and f[1].val == "bar=a"
  doAssert f[2].kind == cmdLongOption and f[2].key == "a" and f[2].val == "c:d"
  doAssert f[3].kind == cmdLongOption and f[3].key == "ab" and f[3].val == ""
  doAssert f[4].kind == cmdShortOption and f[4].key == "c" and f[4].val == ""