optparse-applicative
optparse-applicative copied to clipboard
Using command subparsers only one accepts --help
I have started a simple app https://github.com/obcode/hitlab and I am using subparsers:
I have
args = Conf
<$> strOption
( long "conf"
<> short 'c'
<> value "$(HOME)/.hitlab.conf"
<> metavar "FILE"
<> help "Conf FILE"
)
<*> cmdParser
cmdParser = subparser $
command "create" (info createOptions
(progDesc "Create new repositories for groups"))
<> command "pull" (info pullOptions
(progDesc "Pull from all repos, clones if not present"))
<> command "push" (info pushOptions
(progDesc "Push current repo into all given repos"))
and my subparsers look like
createOptions = Create
<$> (CreateOptions
<$> strOption
( long "prefix"
<> short 'p'
<> metavar "PREFIX"
<> help "Use PREFIX for repositories" )
<*> strOption
( long "desc"
<> short 'd'
<> metavar "DESCRIPTION"
<> help "Use DESCRIPTION for repositories" )
<*> strOption
( long "inputFilename"
<> short 'f'
<> metavar "FILENAME"
<> help "Read moodle groups from FILENAME" )
<*> strOption
( long "output"
<> short 'o'
<> value "gitolite.conf"
<> showDefault
<> metavar "FILENAME"
<> help "write gitolite conf to FILENAME" )
<*> switch
( long "readonly"
<> short 'r'
<> help "no write access for students" )
)
and
pullOptions :: Parser Cmd
pullOptions = Pull
<$> (PullOptions
<$> strOption
( long "user"
<> short 'u'
<> value "git"
<> metavar "USER"
<> help "Git User on remote" )
<*> strOption
( long "host"
<> short 'h'
<> value "ob.cs.hm.edu"
<> metavar "HOST"
<> help "Host running gitolite" )
<*> strOption
( long "port"
<> short 'p'
<> value "8022"
<> metavar "PORT"
<> help "sshd listening on PORT" )
<*> strOption
( long "repos"
<> short 'r'
<> value ""
<> metavar "REPOPREFIX"
<> help "pull only repositories starting with PREFIX" )
<*> strOption
( long "branch"
<> short 'b'
<> value "master"
<> metavar "BRANCH"
<> help "pull BRANCH" )
<*> strOption
( long "openwith"
<> short 'o'
<> value ""
<> metavar "PROGRAM"
<> help "open all repos with changes with PROGRAM" )
)
Now, running --help for pull works:
$ hitlab pull --help
Usage: hitlab pull [-u|--user USER] [-h|--host HOST] [-p|--port PORT]
[-r|--repos REPOPREFIX] [-b|--branch BRANCH]
Pull all repos master branch, clones if not present
Available options:
-u,--user USER Git User on remote
-h,--host HOST Host running gitolite
-p,--port PORT sshd listening on PORT
-r,--repos REPOPREFIX pull only repositories starting with PREFIX
-b,--branch BRANCH pull BRANCH
But not for create or push:
$ hitlab create --help
Invalid option `--help'
Usage: hitlab create (-p|--prefix PREFIX) (-d|--desc DESCRIPTION)
(-f|--template FILENAME) [-o|--template FILENAME]
Create new repositories for groups
What am I missing here? I really do not see the difference. As said before, the full code lives in https://github.com/obcode/hitlab
Is it a bug or my fault?
Looks like #55.
Create! Thanks!