I read through the links above, changed from current stable 1.2.6 to current nightly 64e34778fa7e114b4afc753c7845dee250584167 and experience problems, as seen below.
What is the current status on this situation and on which Nim version can I use the below example snippet? (Was getting confused by the back and forth in those conversations, so I apologise if the answer is already posted somewhere.)
#!/usr/bin/env nim
mode = ScriptMode.Silent
switch("hints", "off")
import
os,
parseopt
var
SDA=false
SDB=false
SDC=false
SDD=false
for kind, key, val in commandLineParams().getopt():
case kind
of cmdArgument:
case key:
of "/dev/sda": SDA = true
of "/dev/sdb": SDB = true
of "/dev/sdc": SDC = true
of "/dev/sdd": SDD = true
of cmdLongOption, cmdShortOption:
discard
of cmdEnd: assert(false)
...
please check whether the problem still exists in git head before posting, see rebuilding the compiler.
Error: type mismatch: got <seq[TaintedString]>
but expected one of:
iterator getopt(p: var OptParser): tuple[kind: CmdLineKind, key, val: TaintedString]
first type mismatch at position: 1
required type for p: var OptParser
but expression 'commandLineParams()' is of type: seq[TaintedString]
expression: getopt(commandLineParams())
and things like
Error: undeclared identifier: 'initOptParser'
var opts: seq[string]
for i in 1 .. paramCount():
opts.add paramStr(i)
for kind, key, val in opts.getopt():
# ETC.
You should remove os from your imports or namespace both paramCount and paramStr to use the system ones.
Greetings,
thank you for your suggestion. I will look into it and try other alternatives, as well.