-
-
Save skiold/4d35fe8bd5de775670ff to your computer and use it in GitHub Desktop.
This file contains 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 | |
import Control.Monad | |
parser :: Parser (IO ()) | |
parser = subparser $ | |
command "add" (info (helper <*> addMode) mempty) | |
<> command "test" (info (pure $ putStrLn "testing") mempty) | |
where | |
addMode :: Parser (IO ()) | |
addMode = subparser $ | |
command "add" (info (pure $ putStrLn "adding message") mempty) | |
<> command "remove" (info (pure $ putStrLn "removing message") mempty) | |
main :: IO () | |
main = join $ execParser $ info (helper <*> parser) mempty | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
from comments on https://www.reddit.com/r/haskell/comments/44zhdk/im_making_a_command_line_argument_parser_inspired/