Nim's Nimble scripts

287 Views Asked by At

Using npm, one can define scripts inside of package.json that can be easily called like

npm run <script-name>

It is very handy to compile/start/lint the project

How are we suppposed to do this with Nimble when using Nim lang?

2

There are 2 best solutions below

1
On

If environment variable XDG_CONFIG_HOME is defined, $XDG_CONFIG_HOME/nim/config.nims or ~/.config/nim/config.nims (POSIX) or %APPDATA%/nim/config.nims (Windows). This file can be skipped with the --skipUserCfg command line option.

$parentDir/config.nims where $parentDir stands for any parent directory of the project file's path. These files can be skipped with the --skipParentCfg command line option.

$projectDir/config.nims where $projectDir stands for the project's path. This file can be skipped with the --skipProjCfg command line option.

A project can also have a project-specific configuration file named $project.nims that resides in the same directory as $project.nim. This file can be skipped with the same --skipProjCfg command line option.

0
On

Found the way, it is called tasks.

You can define any in your .nimble file (nimble init) like this

task greet, "Print a greeting message":
  exec "echo Hello!"

You can then call

nimble greet