Last active
April 5, 2019 05:42
-
-
Save jhrcek/b73c5ef79f7cc0a474ead1df7f7eebbb to your computer and use it in GitHub Desktop.
optparse-applicative demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Options.Applicative (Parser, ParserInfo, command, execParser, fullDesc, | |
| help, helper, info, progDesc, subparser, value) | |
| main :: IO () | |
| main = execParser cliParser >>= print | |
| demo :: Parser Int | |
| demo = subparser | |
| ( command "a" (info (pure 1) (progDesc "A description")) | |
| <> command "b" (info (pure 2) (progDesc "B description")) | |
| ) | |
| cliParser :: ParserInfo Int | |
| cliParser = info (helper <*> demo) fullDesc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment