From 7f5d0b170099704d1a2016e2af1d9bfbde7ea1ad Mon Sep 17 00:00:00 2001 From: defanor Date: Tue, 19 Dec 2017 02:43:21 +0300 Subject: Enable a user to specify a configuration file This covers both command-line options and the "load config" (former "reload config") command. --- Pancake/Command.hs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'Pancake/Command.hs') diff --git a/Pancake/Command.hs b/Pancake/Command.hs index 4c34a19..52ace06 100644 --- a/Pancake/Command.hs +++ b/Pancake/Command.hs @@ -59,7 +59,7 @@ data Command = Quit | Show Int | ShowCurrent | Shortcut String String - | ReloadConfig + | LoadConfig (Maybe FilePath) | SetWidth (Maybe Int) | Redisplay deriving (Show, Eq) @@ -75,7 +75,6 @@ basicCommand = choice . map (\(s, c) -> try (string s <* eof) *> pure c) $ , ("[", Back) , ("]", Forward) , (",", GoTo Nothing RCurrent) - , ("reload config", ReloadConfig) , ("help", Help) , ("?", ShowCurrent) , ("redisplay", Redisplay) @@ -151,7 +150,13 @@ pNat = read <$> many1 digit -- | 'SetWidth' command parser. setWidth :: Parser Command setWidth = string "set width" - *> (SetWidth <$> optionMaybe (spaces *> pNat)) + *> (SetWidth <$> optionMaybe (space *> pNat)) + <* eof + +-- | 'LoadConfig' command parser. +loadConf :: Parser Command +loadConf = string "load config" + *> (LoadConfig <$> optionMaybe (space *> many1 anyChar)) <* eof -- | Command parser. @@ -166,5 +171,6 @@ command c = , saveCurrent "save current" , save "save" , setWidth "set width" + , loadConf "load config" , goTo "follow uri" ]) -- cgit v1.2.3