You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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 only build and exec so people might be inclined to just use that (also in scripts where it is harder to change than in interactive use), but if benchmark is added, suddenly myprog b will fail with an error. Being able to disable the prefix matching can be useful in some cases.
The text was updated successfully, but these errors were encountered:
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.
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:
cmdliner/src/cmdliner_eval.ml
Lines 135 to 137 in b2f03ea
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.The text was updated successfully, but these errors were encountered: