Accessing the command line parameters in a --sup application

Hi to all,

I’d like to build a standalone application (to get rid of the dev environment in production) with a supervision tree and be able to access the eventual command line parameters a user might want to provide.

I generated the application with : mix new webby --sup but I can’t figure out how to access the command line parameters.

As an alternative I’ve made it an escript (I kept what had been generated by --sup):

  • I added the Webby.main(args) function which :
    • parses the arguments provided on the command line
    • and starts the application with validated arguments : Webby.Application.start(:normal, validated_args)
  • I commented out the line mod: {Webby.Application, []} in mix.exs

The issue here is that the application exits immediately after it had executed Webby.main(). Moreover, I’m definitely not sure that dependencies are started properly (this is maybe why it exists immediately ?)

I’d be grateful if anybody could explain how to do this the right way

Thanks in advance