summaryrefslogtreecommitdiff
path: root/src/Command.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Command.hs')
-rw-r--r--src/Command.hs11
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
3module Command 3module Command
4 ( Cmd(..) 4 ( Cmd(..)
@@ -21,7 +21,7 @@ import Data.Maybe (fromMaybe)
21 21
22import Types 22import Types
23 23
24data Cmd = PerformAlt Alteration (Maybe Comment) 24data 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
74parseCmd' :: SequenceM m => [String] -> m Cmd 74parseCmd' :: SequenceM m => [String] -> m Cmd
75parseCmd' [] = return Empty 75parseCmd' [] = return Empty
76parseCmd' args = do 76parseCmd' 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