Creating main Scripts

LFE supports the creation of scripts, and these can be integrated with libraries, allowing for the best of both worlds: a simple collection of useful functions (library) and a means of running them from the command line.

Create a library that also has a script with a main function:

rebar3 new lfe-main special-proj

Which generates:

===> Writing special-proj/
===> Writing special-proj/LICENSE
===> Writing special-proj/rebar.config
===> Writing special-proj/.gitignore
===> Writing special-proj/src/special-proj.lfe
===> Writing special-proj/scripts/main.lfe
===> Writing special-proj/src/

The generated project's main script + function may then be run with:

cd mymain
rebar3 lfe run -- 42

Which will produce the following output:

Running script '/usr/local/bin/rebar3' with args [<<"42">>] ...