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
Currently, optparse-generic supports --help as a special case.
It'd be nice to also support --version as a special case. It's currently possible to support in a record argument like:
dataOpts=Opts{version::Bool}deriving (Generic, ParseRecord)
main =doOpts {..} <- getRecord "main"
when version $doprint version
exitSuccess
do the rest of the stuff
This does not work with a subcommand parser. Or, it kinda does, but you need --version after selecting a sub-command. Or you make version it's own subcommand.
dataCmd=Version | OtherCommandderiving (Generic, ParseRecord)
main =do
cmd <- getRecord "Cmd"case cmd ofVersion->print version
OtherCOmmand-> etc
This can be worked-around with a hack:
main =do
args <- getArgs
when ("--version"`elem` args) $doprint version >> exitSuccess
Opts {..} <- getRecord "main"
etc
But then we don't get pretty documentation on the --version flag.
okay, that's a lot of prelude,
Request
getRecordWithVersion
::ParseRecorda=>IO()--^ Action to call if a `--version` flag is passed->String->IOa
which augments the a parser with the --version flag and calls the special thing.
This would probably be pretty easy to support as an external library, or as app-local code.
The text was updated successfully, but these errors were encountered:
Currently,
optparse-generic
supports--help
as a special case.It'd be nice to also support
--version
as a special case. It's currently possible to support in a record argument like:This does not work with a subcommand parser. Or, it kinda does, but you need
--version
after selecting a sub-command. Or you makeversion
it's own subcommand.This can be worked-around with a hack:
But then we don't get pretty documentation on the
--version
flag.okay, that's a lot of prelude,
Request
which augments the
a
parser with the--version
flag and calls the special thing.This would probably be pretty easy to support as an external library, or as app-local code.
The text was updated successfully, but these errors were encountered: