I am using a Makefile script for compiling Nim programs. However, RSDuck suggested the replacement of Makefile with nimscript. I confess that I didn't know anything about the very existence of nimscript, and I want to thank RSDuck for drawing my attention to it. However, in nimscript, I encountered the same kind of problem that I found in macros: The lack of simple examples. Anyway, here is the script I wrote:
#!/usr/local/bin/nim
mode = ScriptMode.Silent
# Options: Silent, Verbose, Whatif
let
app=paramStr(2)
src= app & ".nim"
exe= app & ".x"
let C= "nim c --hints:off --nimcache:xx -d:danger -o:"
exec C & exe & " " & src
mvFile exe, "./bin/" & exe
# Usage: ./build.nims iterfib
I would appreciate feedback about the above script from members of this forum. The main issues are: (1) I failed in turning hints off; (2) I would like to print a usage message, whenever user forgets the name of the application.
https://nim-lang.org/docs/nims.html https://github.com/kaushalmodi/nim_config/blob/master/config.nims
Check the links may have useful stuff. The syntax and all is the same, so is a little bit of practice and try/error of some stuff that wont work on NimScript. You can check the len of paramStr and if its 0 then echo "Missing arguments".