ndmitchell / cmdargs

Haskell library for command line argument processing
Other
91 stars 12 forks source link

Store unknown flags #36

Open ndmitchell opened 9 years ago

ndmitchell commented 9 years ago

From https://code.google.com/p/ndmitchell/issues/detail?id=470:

Some programs want to accumulate "unknown" flags, i.e. those which aren't otherwise recognised by the program. I'm in two minds about this, since it brings a number of disadvantages:

1) There will be no --help output for these commands, so they are undiscoverable. 2) Given a known flag --bar, then --ba will automatically resolve to --bar, unless there is also a --baa in which case it will be an ambiguous error. The existence or otherwise of commands changes the parser, so having unknown flags can be problematic.

On the other hand, it's something that hledger already does with the -- option, so supporting it more explicitly might give a better experience for them. See this thread for details: http://www.mail-archive.com/haskell-cafe@haskell.org/msg92770.html

@simonmichael says:

Yes, without this (optional) feature it seems hard to pass extra flags through to be handled by a sub-executable. Here's an example: hledger wants to pass some web-specific options through to hledger-web as in https://code.google.com/p/hledger/issues/detail?id=64 .

Not quite so hard as all that: http://joyful.com/darcsden/simon/hledger/patch/20110923141027-3c3f9 . But it would still be nice not to have to type --.

LeventErkok commented 4 years ago

@ndmitchell Is there any update on this? It would be nice if the program gets access to "unknown flags" instead of cmdargs just throwing an error for better error reporting and integration with, say, editors.

ndmitchell commented 4 years ago

@LeventErkok no update, and I don't expect there to be one in the near future. Would still be nice to have, if someone wants to submit a patch.