data ListOptions = OneLine | MultiLine
data PrimerCommand =
Add Volume Location
| New Volume Char Char Location
| List ListOptions
hsubparser
( command "add" (info addCommand (progDesc "Add a primer location to the index"))
<> command "new" (info newCommand (progDesc "Add a new AlBhed Primer to the index"))
<> command "ls" (info listCommand (progDesc "List all AlBhed Primers in the index"))
)
List <$> listOpts
where
listOpts = flag MultiLine OneLine (long "oneline" <> short '1' <> help "Print all primers on one line if possible")
New <$> volume <*> char "FROM" <*> char "TO" <*> location
where
char = argument Parser.singleChar . metavar
Add <$> volume <*> location
argument parseVolume (metavar "VOLUME")
Location.Location
<$> argument Parser.printableText (metavar "AREA")
<*> optional (argument Parser.printableText (metavar "SECTION"))
eitherReader $
(first parseError . input) >=> volume
where
parseError = const "Failed to parse volume number"
input = readEither @Int
volume = maybeToEither "Volume must be 1 to 26" . AlBhed.toVolume