From 6ce5de5a227267e359aa3c38344e3858f035287d Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Sun, 8 May 2016 01:05:00 +0200 Subject: command interpretation --- src/Command.hs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/Command.hs') diff --git a/src/Command.hs b/src/Command.hs index 3616729..659d14d 100644 --- a/src/Command.hs +++ b/src/Command.hs @@ -1,4 +1,4 @@ -{-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE FlexibleContexts, OverloadedStrings #-} module Command ( Cmd(..) @@ -21,7 +21,7 @@ import Data.Maybe (fromMaybe) import Types -data Cmd = PerformAlt Alteration (Maybe Comment) +data Cmd = PerformAlt Alteration Comment | ShowTip | ShowHistory (Maybe Integer) | Dump @@ -74,7 +74,7 @@ parseCmd = parseCmd' . split parseCmd' :: SequenceM m => [String] -> m Cmd parseCmd' [] = return Empty parseCmd' args = do - tip <- fmap snd <$> gets MaxPQueue.getMax + tip <- fmap snd <$> gets (MaxPQueue.getMax . ctxSequence) let runParser = execParserPure (prefs $ showHelpOnError) (cmdParser tip `info` progDesc "sequence - A tracker for combat sequences in Contact (a pen&paper rpg by Uhrwerk)") args return $ mapResult runParser @@ -121,8 +121,5 @@ cmdParser tip = hsubparser $ mconcat [ command "quit" $ pure Quit `info` progDes sequenceValue = argument auto (help "Sequence value adjustment" <> metavar "SEQUENCE") sequenceValue' = argument auto (help "Sequence value" <> metavar "SEQUENCE") - comment = toMaybe . fmap Text.pack <$> optional (strArgument $ help "Comment to record in history together with this action" <> metavar "COMMENT") - toMaybe (Just t) - | Text.null t = Nothing - | otherwise = Just t + comment = fromMaybe "" . fmap Text.pack <$> optional (strArgument $ help "Comment to record in history together with this action" <> metavar "COMMENT") toMaybe Nothing = Nothing -- cgit v1.2.3