diff options
Diffstat (limited to 'src/Command.hs')
-rw-r--r-- | src/Command.hs | 11 |
1 files changed, 4 insertions, 7 deletions
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 @@ | |||
1 | {-# LANGUAGE FlexibleContexts #-} | 1 | {-# LANGUAGE FlexibleContexts, OverloadedStrings #-} |
2 | 2 | ||
3 | module Command | 3 | module Command |
4 | ( Cmd(..) | 4 | ( Cmd(..) |
@@ -21,7 +21,7 @@ import Data.Maybe (fromMaybe) | |||
21 | 21 | ||
22 | import Types | 22 | import Types |
23 | 23 | ||
24 | data Cmd = PerformAlt Alteration (Maybe Comment) | 24 | data Cmd = PerformAlt Alteration Comment |
25 | | ShowTip | 25 | | ShowTip |
26 | | ShowHistory (Maybe Integer) | 26 | | ShowHistory (Maybe Integer) |
27 | | Dump | 27 | | Dump |
@@ -74,7 +74,7 @@ parseCmd = parseCmd' . split | |||
74 | parseCmd' :: SequenceM m => [String] -> m Cmd | 74 | parseCmd' :: SequenceM m => [String] -> m Cmd |
75 | parseCmd' [] = return Empty | 75 | parseCmd' [] = return Empty |
76 | parseCmd' args = do | 76 | parseCmd' args = do |
77 | tip <- fmap snd <$> gets MaxPQueue.getMax | 77 | tip <- fmap snd <$> gets (MaxPQueue.getMax . ctxSequence) |
78 | let | 78 | let |
79 | runParser = execParserPure (prefs $ showHelpOnError) (cmdParser tip `info` progDesc "sequence - A tracker for combat sequences in Contact (a pen&paper rpg by Uhrwerk)") args | 79 | runParser = execParserPure (prefs $ showHelpOnError) (cmdParser tip `info` progDesc "sequence - A tracker for combat sequences in Contact (a pen&paper rpg by Uhrwerk)") args |
80 | return $ mapResult runParser | 80 | return $ mapResult runParser |
@@ -121,8 +121,5 @@ cmdParser tip = hsubparser $ mconcat [ command "quit" $ pure Quit `info` progDes | |||
121 | sequenceValue = argument auto (help "Sequence value adjustment" <> metavar "SEQUENCE") | 121 | sequenceValue = argument auto (help "Sequence value adjustment" <> metavar "SEQUENCE") |
122 | sequenceValue' = argument auto (help "Sequence value" <> metavar "SEQUENCE") | 122 | sequenceValue' = argument auto (help "Sequence value" <> metavar "SEQUENCE") |
123 | 123 | ||
124 | comment = toMaybe . fmap Text.pack <$> optional (strArgument $ help "Comment to record in history together with this action" <> metavar "COMMENT") | 124 | comment = fromMaybe "" . fmap Text.pack <$> optional (strArgument $ help "Comment to record in history together with this action" <> metavar "COMMENT") |
125 | toMaybe (Just t) | ||
126 | | Text.null t = Nothing | ||
127 | | otherwise = Just t | ||
128 | toMaybe Nothing = Nothing | 125 | toMaybe Nothing = Nothing |