ManageIQ / optimist

Optimist is a commandline option parser for Ruby that just gets out of your way.
https://manageiq.org/optimist/
MIT License
249 stars 36 forks source link

Add help message comments for constraints #132

Open Fryguy opened 2 years ago

Fryguy commented 2 years ago

From https://github.com/ManageIQ/optimist/pull/130#issuecomment-1100475979, @nanobowers wrote:

...should there any default notation in the help message for exclusivity clauses? If the developer uses either:, conflicts: or depends, seems like the only good way to find out is to try it and get an error message, or the developer would have to manually note it with the banner message.

nanobowers commented 4 months ago

I was thinking about this a little more and am not sure the best way to implement it. One thought was an addition to each line:

Options:
  -c, --cone       Ice cream cone
  -z, --zippy      It zips (conflicts with --zapzy)
  -a, --zapzy      It zapz (conflicts with --zippy)
  -b, --big-bug    Madagascar cockroach

It's possible to have multiple things in the conficts/depends/either so it may get lengthy. I think it might be possible to create multiple depends/conflicts/either that affect the same option so the line could be wildly long. Another option may be to represent with some notation on the line and then later write the constraints below:

Options:
  -c, --cone       Ice cream cone (*)
  -z, --zippy      It zips (**)
  -a, --zapzy      It zapz (**)
  -b, --big-bug    Madagascar cockroach (*)
Constraints:
 * : depends [ --cone, --big-bug ]
 ** : conflicts [--zippy, --zapzy]

I have created complex banners in the past and depending on how it's done the placement of the Constraints: section in the help may be inconvenient.