summaryrefslogtreecommitdiff
path: root/Pancake/Command.hs
diff options
context:
space:
mode:
authordefanor <defanor@uberspace.net>2017-12-19 02:43:21 +0300
committerdefanor <defanor@uberspace.net>2017-12-19 02:43:21 +0300
commit7f5d0b170099704d1a2016e2af1d9bfbde7ea1ad (patch)
tree33a28920e6d60e73e154c8185e7318c473ec01d4 /Pancake/Command.hs
parent6e368bc36c603a23e57a5baa14556446a8603a8e (diff)
Enable a user to specify a configuration file
This covers both command-line options and the "load config" (former "reload config") command.
Diffstat (limited to 'Pancake/Command.hs')
-rw-r--r--Pancake/Command.hs12
1 files changed, 9 insertions, 3 deletions
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"
])