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

parse/3 with {command, true|false} option #43

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sskorokhodov
Copy link
Contributor

{command, true} option directs to stop parsing at the first unrecognized token. It is useful when the program has subcommands with their own sets of options. The rest of the arguments is returned untouched as non-option arguments and can be parsed again as a different set of options.

I understand that it is a more intrusive change compared to the previous my PRs. But it solves the first problem I got into using the library.

@sskorokhodov
Copy link
Contributor Author

Sorry for bothering. Do you have any thoughts about the PR?

@jcomellas
Copy link
Owner

@sskorokhodov Sorry for not answering before, but I was too busy to do a proper analysis of the changes.

I did a first pass at reviewing the PR and it looks fine. I would change the name of the option to something other than command. This is more like an optional termination. In fact, maybe the option could also apply to the GNU getopt termination marker (--) that is currently supported.

I will look at it during the day and leave additional feedback.

@sskorokhodov
Copy link
Contributor Author

Thanks for the response.

I agree with you about the option name. The other names I considered are:

  • multilevel
  • expect_command
  • in_order (as in clojure.tools/cli)

It's also possible to use something like {terminator, any} or {terminator, "my-terminator"} which is by default {terminator, "--"}. The atom any can be replaced by argument or something similar.

Waiting for the further feedback.

`{command, true}` option directs to stop parsing at the first
unrecognized token. It is useful when the program has subcommands with their
own sets of options. The rest of the arguments is returned untouched as
non-option arguments and can be parsed again as a different set of options.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants