Closed Leonidas-from-XIV closed 1 year ago
I have said more than once here and there that I regret doing the prefix matching behaviour. On the other hand I also secretly think it's a nice thing to have for interactive users.
In my dreams I believe people are wise enough and do understand that in scripts you should not rely on the prefix behaviour. Of course they are not.
In any case I think it's too late to change these things now and I'm not fond on configurability. More than the wrong choices it took I like the uniform way all cmdliner using programs behave.
Is this meant to apply to args as well? I was surprised to find that with the arg let dry_run = Arg.(value & flag & info [ "d"; "dry-run" ])
, I am able to pass every suffix of dry-run
, instead of the declared options.
Yes, see the manual.
Hi,
I was surprised to learn that Cmdliner does prefix mapping for names of commands in groups by default. This is pretty cool and can make for convenient CLI usage. But it would also be useful to be able to disable that behavior. Upon taking a look at the code where it is evaluated it seems like it unconditionally constructs a trie and matches the names: https://github.com/dbuenzli/cmdliner/blob/b2f03ea0427feaae59e2a0e02ff020f0d78ccbcf/src/cmdliner_eval.ml#L135-L137 so it doesn't look like that is possible at the moment.
Rationale: When evolving some software commands get added over time, while hopefully old commands keep working. The prefix match can be tricky, because
myprog b
works if there is onlybuild
andexec
so people might be inclined to just use that (also in scripts where it is harder to change than in interactive use), but ifbenchmark
is added, suddenlymyprog b
will fail with an error. Being able to disable the prefix matching can be useful in some cases.