diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-07-17 16:51:00 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-07-17 16:51:00 -0400 |
| commit | 7e53d16aa18f343de70830219095fbf8e1566a2f (patch) | |
| tree | b31044c089a6099a7b2ebfed27c3de6a21085f93 /src/Propellor/Property/ConfFile.hs | |
| parent | e2792f93555c0d35313c976604c4ee20f3dd36e2 (diff) | |
| parent | c987a3a3bd14171071b85c5937773a47b23859ff (diff) | |
Merge branch 'master' into joeyconfig
Diffstat (limited to 'src/Propellor/Property/ConfFile.hs')
| -rw-r--r-- | src/Propellor/Property/ConfFile.hs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/Propellor/Property/ConfFile.hs b/src/Propellor/Property/ConfFile.hs index ce092ec9..76d52bd9 100644 --- a/src/Propellor/Property/ConfFile.hs +++ b/src/Propellor/Property/ConfFile.hs @@ -9,6 +9,7 @@ module Propellor.Property.ConfFile ( IniSection, IniKey, containsIniSetting, + lacksIniSetting, hasIniSection, lacksIniSection, iniFileContains, @@ -93,6 +94,19 @@ containsIniSetting f (header, key, value) = adjustIniSection go (l:ls) = if isKeyVal l then confline : ls else l : go ls isKeyVal x = (filter (/= ' ') . takeWhile (/= '=')) x `elem` [key, '#':key] +-- | Removes a key=value setting from a section of an .ini file. +-- Note that the section heading is left in the file, so this is not a +-- perfect reversion of containsIniSetting. +lacksIniSetting :: FilePath -> (IniSection, IniKey, String) -> Property UnixLike +lacksIniSetting f (header, key, value) = adjustIniSection + (f ++ " section [" ++ header ++ "] lacks " ++ key ++ "=" ++ value) + header + (filter (/= confline)) + id + f + where + confline = key ++ "=" ++ value + -- | Ensures that a .ini file exists and contains a section -- with a given key=value list of settings. hasIniSection :: FilePath -> IniSection -> [(IniKey, String)] -> Property UnixLike |
