getopt icon indicating copy to clipboard operation
getopt copied to clipboard

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

Open sskorokhodov opened this issue 6 years ago • 3 comments

{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 avatar Mar 30 '18 17:03 sskorokhodov

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

sskorokhodov avatar May 03 '18 16:05 sskorokhodov

@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.

jcomellas avatar May 08 '18 12:05 jcomellas

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.

sskorokhodov avatar May 08 '18 12:05 sskorokhodov