dbuenzli / cmdliner

Declarative definition of command line interfaces for OCaml
http://erratique.ch/software/cmdliner
ISC License
296 stars 56 forks source link

`-` in info names #152

Closed giltho closed 2 years ago

giltho commented 2 years ago

Hi!

We noticed quite surprising behaviour in Arg.info: if you define a flag that has a dash, you can remove anything after the dash and it still works.

For example, for a flag defined used Arg.info [ "v", "with-verbose"], I would expect to be able to call my program saying ./prog.exe -v or ./prog.exe --with-verbose, but Cmdliner will also let you use ./prog.exe --with which unexpected.

Is this intended behaviour? Thanks!

samoht commented 2 years ago

It's actually works with any prefix, ie../prog.exe --wi will also work :-)

giltho commented 2 years ago

oohhhh, so that is expected behaviour?

dbuenzli commented 2 years ago

oohhhh, so that is expected behaviour?

The behaviour of your cli is documented here.

So yes it is expected behaviour. It's both a curse and a blessing and it's still unclear to me whether this was a good idea or not.

For interactive users it means you should not be shy to use long descriptive names that they can abbreviate as they wish.

For script writers it means that if they do not use the full names, their scripts can break in the future when you add new options. So always instruct your users to write fully qualified option names in their scripts.