artificery
artificery copied to clipboard
OptionParser Dropping Arguments
I'm trying to run a script in Distillery, which under the covers runs:
elixir -e Mix.Releases.Runtime.Control.main --logger-sasl-reports false -- eval --mfa MyApp.run/1 --argv -- --my-arg-1 --my-arg-2
However, in post_process_command/3, after parsing eval with it's options "mfa" and "argv" correctly, we hit the "else" case, which causes us to incorrectly parse the rest of the args after the --. In the case above, the args are dropped, but even in the case of non-hyphenated args, the behavior is inconsistent (as it's trying to parse them as further commands).
I suggest that we either a) dispatch immediately after parsing a command, instead of arguments changed during option parsing, so go back to parse_args, or b) allow users to input some value that causes command to stop processing and dispatch with the args.
Option b could work as:
elixir -e Mix.Releases.Runtime.Control.main --logger-sasl-reports false -- eval --mfa MyApp.run/1 --argv --extra --my-arg-1 --my-arg-2
When the algorithm sees --extra, it dispatches the rest of the argv instead of continuing to process.
Happy for thoughts on this.
Could you take a look at 0.3.0? I've fixed the handling of -- in that release. Sorry for the delay!