-
Notifications
You must be signed in to change notification settings - Fork 122
Open
Description
Given an option of a sum type (Foo in this example):
module Main where
import Options.Applicative
data Opts = Opts
{ flag :: Foo
, ok :: Bool
}
deriving (Show)
data Foo = Bar | Baz | Quux deriving (Read, Show)
opts :: Parser Opts
opts =
Opts
<$> option auto (help "how to do it" <> long "flag" <> value Bar <> showDefault)
<*> option auto (help "is it ok" <> long "ok" <> value True <> showDefault)
main :: IO ()
main = do
opts' <- execParser (info (opts <**> helper) fullDesc)
print opts'This is the help output currently:
Usage: optest [--flag ARG] [--ok ARG]
Available options:
--flag ARG how to do it (default: Bar)
--ok ARG is it ok (default: True)
-h,--help Show this help text
Instead of --flag ARG how to do it (default: Bar) I would like something like --flag ARG how to do it (default: Bar, allowed values: Foo, Bar, Baz). Can optparse-applicative do this?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels