From 8c6245fac35cdc9a1ef743d29eea9176448d350d Mon Sep 17 00:00:00 2001 From: Frederick Yin Date: Mon, 13 Mar 2023 18:23:48 +0800 Subject: Package into cabal project --- src/Main.hs | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/Main.hs (limited to 'src/Main.hs') diff --git a/src/Main.hs b/src/Main.hs new file mode 100644 index 0000000..1b4996f --- /dev/null +++ b/src/Main.hs @@ -0,0 +1,44 @@ +import Options.Applicative +import Game (Game(..), Setup(..), beginGame) + +setup :: Parser Setup +setup = Setup + <$> option auto + ( short 'n' + <> long "player-number" + <> metavar "n" + <> value 4 + <> help "n players, n must be larger than 2 (default: 4)" + ) + <*> option auto + ( short 'r' + <> long "rounds" + <> metavar "r" + <> value 1 + <> help "play r rounds, r must be at least 1 (default: 1)" + ) + <*> option auto + ( short 'd' + <> long "decks" + <> metavar "d" + <> value 2 + <> help "use d decks 52 cards each, d must be at least 2 (default: 2)" + ) + <*> option auto + ( short 'c' + <> long "initial-cards" + <> metavar "c" + <> value 5 + <> help "deal c cards per player, c must be at least 2 (default: 5)" + ) + <*> switch + ( short 'a' + <> long "auto" + <> help "run in demo mode" + ) + +main :: IO () +main = do + let opts = info (setup <**> helper) (fullDesc <> progDesc "One Card") + beginGame =<< execParser opts + return () -- cgit v1.2.3