Quick 1 liner: How does one start an OTP application and pass command-line args to it?
I wanted be able to start an OTP application in a generic "UNIX" way, being able to pass command-line arguments parsed by getopts. So, I have an erlang escript which uses the getopt library to handle parsing of command-line arguments.
shino's answer got me on the right path:
- I have my escript do the getopts parsing
- The escript then loads the application description into memory with application:load/1
- I then use application:set_env/3 to store the CLI args
- Now, launch the application with application:start/2
- Once the application launches, the arguments can be accessed via application:get_env/2