bitwalker / bitwalker/artificery
OptionParser Dropping Arguments
- Dominant language
- Elixir
- Stars
- 132
- Forks
- 17
- PR merge metrics
- No merged PRs in 30d
Description
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.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at post_process_command/3 and reproduce the shown `elixir -e Mix.Releases.Runtime.Control.main` command, including `eval`, `--mfa`, `--argv`, and arguments after `--`. Define and implement a dispatch behavior that preserves the remaining argv instead of dropping it or treating it as further commands; done means both hyphenated and non-hyphenated arguments are passed through consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- elixir
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 28/100