Hi, coming from python i am new to Nim.
I am using argparse package like this:
p = newParser("tradl"):
option("-l", "--language")
option("-a", "--amount")
option("-d", "--dir")
option("-s", "--search")
var opts = p.parse()
in my understanding, opts should be a global variable, thus accessable in procedures. i am accesing opts in this procedure:
dl(url: string): bool =
try:
var client = newHttpClient()
let content = client.getContent(url)
try:
writefile(joinpath(opts.dir, filename), content)
except IOError:
log(lvlError,"Error writing file " & filename)
return false
except HttpRequestError:
log(lvlError,"Error downloading " & item.title)
return false
return true
This results in:
: undeclared identifier 'opts'
What am i doing wrong?
coming from python i am new to Nim
What am i doing wrong?
Defining opts after your proc? (You can do that in Python, but not in Nim)
Thank you miran. Pascal is too long ago and i was dabbling to much in Python.
I love Nim so far. It's the perfect combination of the easy python syntax and the flexibility of C. Now we have to create some of our favourite libraries (like Pendulum eg) for Nim :)