-
Notifications
You must be signed in to change notification settings - Fork 113
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
Command doesn't allow specification of an "end of flags" marker #24
Comments
Yes, this came up in earlier discussions about supporting "-" as a valid filename. It can be current be written by using the Command.Spec.escape flag (which can only be passed once) to escape the parser and pass through all remaining arguments. It's worth considering if -- should be the default escape flag, which is present unless another escape flag supersedes it. -anil On 4 Sep 2013, at 11:39, Hugo Duncan notifications@github.com wrote:
|
Thanks for pointing to |
You have to create a parameter named "--". For instance: open Core.Std
let main args () =
let args = Option.value args ~default:[] in
List.iter args ~f:print_endline
;;
let () =
let spec =
Command.Spec.(empty
+> flag "--" escape ~doc:" stop processing command line arguments")
in
Command.run (Command.basic ~summary:"Blah." spec main) $ ./foo -- a -b c
a
-b
c |
Ahh, the When invoking the above without $ ./foo a b c
...
too many anonymous arguments My assumption was that |
This doesn't work because the Command library has some deficiencies... One of them being that it's hard to stop processing arguments as flags and then continue processing them. janestreet/core#24 has more info about the way this currently works.
Some programs take option like arguments (i.e. options starting with --) as data. In other option processing libraries,
--
can be used to explicitly mark the end of options to be processed.While we can workaround this by manually splitting the argument list before passing it to
Command.run
, it would be great to see support for this in Command.The text was updated successfully, but these errors were encountered: