Normalize commandline parser names
This commit is contained in:
parent
bc27d7187e
commit
15722908f4
1 changed files with 12 additions and 11 deletions
23
app/Main.hs
23
app/Main.hs
|
@ -21,8 +21,8 @@ selectLSystem ls s = case find (\x -> name x == s) ls of
|
||||||
Just x -> Right x
|
Just x -> Right x
|
||||||
Nothing -> Left $ "Cannot find L-system \"" ++ s ++ "\". Use -l to find all available L-systems."
|
Nothing -> Left $ "Cannot find L-system \"" ++ s ++ "\". Use -l to find all available L-systems."
|
||||||
|
|
||||||
lsystem :: Parser (LSystem Char)
|
lsystemParser :: Parser (LSystem Char)
|
||||||
lsystem = argument (eitherReader (selectLSystem lsystems))
|
lsystemParser = argument (eitherReader (selectLSystem lsystems))
|
||||||
(metavar "LSYSTEM"
|
(metavar "LSYSTEM"
|
||||||
<> help "L-system to generate"
|
<> help "L-system to generate"
|
||||||
<> showDefaultWith name
|
<> showDefaultWith name
|
||||||
|
@ -30,8 +30,8 @@ lsystem = argument (eitherReader (selectLSystem lsystems))
|
||||||
<> completeWith (map name lsystems)
|
<> completeWith (map name lsystems)
|
||||||
<> completer (listCompleter (map name lsystems)))
|
<> completer (listCompleter (map name lsystems)))
|
||||||
|
|
||||||
iterations :: Parser Integer
|
iterationsParser :: Parser Integer
|
||||||
iterations = option auto
|
iterationsParser = option auto
|
||||||
(long "iterations"
|
(long "iterations"
|
||||||
<> short 'n'
|
<> short 'n'
|
||||||
<> help "Number of iterations"
|
<> help "Number of iterations"
|
||||||
|
@ -39,8 +39,8 @@ iterations = option auto
|
||||||
<> value 5
|
<> value 5
|
||||||
<> metavar "N")
|
<> metavar "N")
|
||||||
|
|
||||||
listLSystems :: Parser (a -> a)
|
listLSystemsParser :: Parser (a -> a)
|
||||||
listLSystems = infoOption (printList lsystems)
|
listLSystemsParser = infoOption (printList lsystems)
|
||||||
(long "list-lsystems"
|
(long "list-lsystems"
|
||||||
<> short 'l'
|
<> short 'l'
|
||||||
<> help "List all available L-systems")
|
<> help "List all available L-systems")
|
||||||
|
@ -69,17 +69,18 @@ colorParser = option (eitherReader readRGB)
|
||||||
Right _ -> Right $ makeColorI 255 255 255 255
|
Right _ -> Right $ makeColorI 255 255 255 255
|
||||||
Left s -> Left s
|
Left s -> Left s
|
||||||
|
|
||||||
whiteBackground :: Parser Bool
|
whiteBackgroundParser :: Parser Bool
|
||||||
whiteBackground = switch
|
whiteBackgroundParser = switch
|
||||||
(long "white-background"
|
(long "white-background"
|
||||||
<> short 'w'
|
<> short 'w'
|
||||||
<> help "Use a white background")
|
<> help "Use a white background")
|
||||||
|
|
||||||
options :: Parser Options
|
optionsParser :: Parser Options
|
||||||
options = Options <$> lsystem <*> iterations <*> colorParser <*> whiteBackground
|
optionsParser = Options <$>
|
||||||
|
lsystemParser <*> iterationsParser <*> colorParser <*> whiteBackgroundParser
|
||||||
|
|
||||||
opts :: ParserInfo Options
|
opts :: ParserInfo Options
|
||||||
opts = info (options <**> listLSystems <**> helper)
|
opts = info (optionsParser <**> listLSystemsParser <**> helper)
|
||||||
( fullDesc
|
( fullDesc
|
||||||
<> progDesc "Generate and draw an L-system"
|
<> progDesc "Generate and draw an L-system"
|
||||||
<> header "lsystems -- Generate L-systems")
|
<> header "lsystems -- Generate L-systems")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue