diff options
| author | Joey Hess <joeyh@joeyh.name> | 2017-07-17 12:51:40 -0400 |
|---|---|---|
| committer | Joey Hess <joeyh@joeyh.name> | 2017-07-17 12:51:40 -0400 |
| commit | 1522d270077abad43a6d8d7fea2bd8163ed912fd (patch) | |
| tree | ff9cdf4b9a12b4ad69fd8dece051e41de596e91f /src/Propellor/Property/ConfFile.hs | |
| parent | b6d650730be9369b89623f46cb773dcc880630cb (diff) | |
Propellor.Property.LightDM.autoLogin: Made revertable.
* Propellor.Property.LightDM.autoLogin: Made revertable.
(minor API change)
* Propellor.Property.Conffile: Added lacksIniSetting.
This commit was sponsored by Jack Hill on Patreon.
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 |
