diff options
Diffstat (limited to 'src/Config.hs')
| -rw-r--r-- | src/Config.hs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Config.hs b/src/Config.hs index 15ce791..3c897f6 100644 --- a/src/Config.hs +++ b/src/Config.hs @@ -26,6 +26,7 @@ import Util -- channel freenode #haskell fn-haskell -- channel liberachat #haskell haskell -- channel liberachat #xmonad xmonad +-- note fn-haskell Extracted from <i>old</i> logs! -- ``` -- -- Lines starting with '#' are ignored. @@ -45,6 +46,8 @@ data Config' (stage :: ConfigStage) = Config , confLogsDir :: FilePath , confPort :: Int -- ^ Port at which to host the HTTP server + , confNotes :: Map Text Text + -- ^ alias => note; user-facing note about the logs for this channel , econfChannels :: IfFull stage [Channel] -- ^ Network-channel pairs, in user-specified order @@ -90,6 +93,7 @@ initConfig = Config { uconfChannels = SnocNil , confLogsDir = error "config: Log directory not set with 'logs'" , confPort = 8000 + , confNotes = mempty , econfChannels = () , econfChan2Alias = () , econfAlias2Chan = () @@ -120,6 +124,13 @@ parseLine conf line = | all (not . null) [network, chan, alias] -> conf { uconfChannels = uconfChannels conf `Snoc` (T.pack network, T.pack chan, T.pack alias) } _ -> error $ "config: Invalid channel spec: " ++ trim rest + "note" -> + case break (== ' ') (dropWhile isSpace rest) of + (alias, ' ' : note) -> + conf { confNotes = + Map.insertWith (error ("config: Duplicate note for '" ++ alias ++ "'")) + (T.pack alias) (T.pack note) (confNotes conf) } + _ -> error "config: Invalid note line, no note" _ -> error $ "config: Invalid line with command '" ++ cmd ++ "'" where trim :: String -> String |
