例があります: 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
したがって、デフォルトでは、引数を使用しない場合、使用情報が表示されます。引数なしでケースを使用し、[カスタム引数] を 1 つ使用したい (カスタム引数を使用すると、エラーが発生しますInvalid argument 'regreg'
:)
ここで空のカスタム引数を処理するにはどうすればよいですか?