implemented service renaming

This commit is contained in:
Jonathan Lamothe
2018-12-31 15:27:36 -05:00
parent 8b71454445
commit f686fb7412
2 changed files with 43 additions and 7 deletions

View File

@@ -24,6 +24,7 @@ module Util
( menu
, run
, withService
, ifServExists
, setService
, req
, tryReq
@@ -82,6 +83,17 @@ withService srv fb act = do
Nothing -> fb
Just x -> act x
ifServExists
:: String
-> S.StateT Status IO a
-> S.StateT Status IO a
-> S.StateT Status IO a
ifServExists s x y = do
db <- S.gets $ view database
if pwHasService s db
then x
else y
setService :: String -> PWData -> S.StateT Status IO ()
setService k = S.modify . over database . pwSetService k