PMunch/nimcr

adding extra flags

Closed this issue · 9 comments

Hi.
Thanks for this tool. It is very handy.
However I am using httpclient in a script and the code should be compiled with -d:ssl option.
Is there any way to config nimcr to make that option default?
Thanks

Thanks, always fun to see people using the things you make :)

Well, nimcr doesn't out of the box support passing arguments. But what you can do is create a nim.cfg file next to the script file and the Nim compiler should use that. For more information you can look at this. I might consider adding support for arbitrary options along with the shebang however.

Thanks for the reply and link

I don't like the idea of adding another file with each script.
I was thinking about adding the flag to nimcr and reinstall it. I guess that's easier !

Added options passing now (along with defaulting to -d:release), see the "Passing options" section of the readme (now moved to base directory so GitHub can see it).

That's great!
Thanks

No problem, if you find it sufficient I'll close this issue :)

unfortunately not working
I have:
#!/usr/bin/env nimcr c -d:ssl

which gives this error
"/usr/bin/env: ‘nimcr c -d:ssl’: No such file or directory"

Hmm, yeah that is a known issue with shebangs. I've had luck with both linking directly to nimcr and just using #!nimcr c -d:ssl with nimcr in my path.

#!nimcr c -d:ssl worked though!!!
Thank you very much.
It works great :)

I've now added support for passing all arguments as a string, so you could now also do:

#! /usr/bin/env nimcr "c -d:ssl"

I now consider this properly solved :)

As an aside I also added support for passing arguments to the script itself if you append "--" to the end of your argument list (see the example file).