Example: https://github.com/pcapriotti/optparse-applicative/blob/master/tests/Examples/Cabal.hs#L46-L62
parser :: Parser Args
parser = runA $ proc () -> do
opts <- asA commonOpts -< ()
cmds <- (asA . hsubparser)
( command "install"
(info installParser
(progDesc "Installs a list of packages"))
<> command "update"
(info updateParser
(progDesc "Updates list of known packages"))
<> command "configure"
(info configureParser
(progDesc "Prepare to build the package"))
<> command "build"
(info buildParser
(progDesc "Make this package ready for installation")) ) -< ()
A version >>> A helper -< Args opts cmds
...
pinfo :: ParserInfo Args
pinfo = info parser
( progDesc "An example modelled on cabal" )
main :: IO ()
main = do
r <- execParser pinfo
print r
So, and by default, when I do not use arguments, it shows usage information. I want to use a case with no arguments, or with one [User argument] (with user I get the following error: Invalid argument 'regreg')
How can I handle empty and custom arguments here?
source
share