Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"to_end" positional_arg's shouldn't include other types of arguments (switch, arg, etc.) #9

Open
mdwagner opened this issue Dec 30, 2021 · 1 comment
Labels
bug Something isn't working

Comments

@mdwagner
Copy link
Contributor

Getting this weird behavior where positional_arg with to_end: true will include all arguments before or after the positional argument.

Ex (other args before positional):

$ lucky importmap.pin --download -e production -f jspm react react-dom
download? # => true
env # => "production"
from # => "jspm"
packages # => ["--download", "-e", "production", "-f", "jspm", "react", "react-dom"]

Ex (other args after postional):

$ lucky importmap.pin react react-dom --download -e production -f jspm
download? # => true
env # => "production"
from # => "jspm"
packages # => ["react", "react-dom", "--download", "-e", "production", "-f", "jspm"]

If both aren't allowed, then at least the one before the positional_arg should work.
Expected:

$ lucky importmap.pin --download -e production -f jspm react react-dom
download? # => true
env # => "production"
from # => "jspm"
packages # => ["react", "react-dom"]
@jwoertink jwoertink added the bug Something isn't working label Dec 30, 2021
@mdwagner
Copy link
Contributor Author

Looking at the code for task.cr and OptionParser (stdlib), it appears you can just use the args passed to parser.parse(args) (which is ARGV be default) and it removes all the arguments parsed, which just leaves the positional arguments. OptionParser also has an unknown_args method for those left over args not parsed, so maybe Lucky can use that instead? Currently, I saw task.cr uses the args from ARGV before they are parsed by OptionParser, which is why they have a reference to them even though OptionParser removes them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants