ldif 0.0.8 → 0.0.9
raw patch · 3 files changed
+22/−29 lines, 3 filesdep ~cmdargsPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: cmdargs
API changes (from Hackage documentation)
Files
- ldif.cabal +2/−2
- src/diffLDIF.hs +10/−14
- src/ldifmodify.hs +10/−13
ldif.cabal view
@@ -1,5 +1,5 @@ Name: ldif-Version: 0.0.8+Version: 0.0.9 License: BSD3 License-File: LICENSE Synopsis: The LDAP Data Interchange Format (LDIF) parser @@ -56,7 +56,7 @@ base < 5, filepath, containers,- cmdargs,+ cmdargs >= 0.2, directory, parsec >= 2.1.0, Cabal >= 1.4
src/diffLDIF.hs view
@@ -14,22 +14,18 @@ data DiffLdif = DiffLdif { srcFile :: FilePath , dstFile :: FilePath } deriving (Show, Data, Typeable) -defaultCfg = mode $ DiffLdif { srcFile = def &= typFile & flag "s" & text "Source LDIF File"- , dstFile = def &= typFile & flag "t" & text "Target LDIF File" }--verifyCfg :: DiffLdif -> IO ()-verifyCfg (DiffLdif [] []) = do - msg <- cmdArgsHelp progDesc [defaultCfg] Text- error msg-verifyCfg (DiffLdif [] _) = error "Missing Source LDIF File parameter (-s)"-verifyCfg (DiffLdif _ []) = error "Missing Target LDIF File parameter (-t)"-verifyCfg (DiffLdif _ _ ) = return ()+defaultCfg = DiffLdif { srcFile = def &= typFile &= name "s" &= help "Source LDIF File"+ , dstFile = def &= typFile &= name "t" &= help "Target LDIF File" } main = do- cfg <- cmdArgs progDesc [defaultCfg]- verifyCfg cfg- ml1 <- parseLDIFFile (srcFile cfg)- ml2 <- parseLDIFFile (dstFile cfg)+ cfg <- cmdArgs defaultCfg+ execute cfg++execute (DiffLdif [] _ ) = putStrLn "Error: -s source file is mandatory" +execute (DiffLdif _ [] ) = putStrLn "Error: -t target file is mandatory"+execute (DiffLdif src dst) = do+ ml1 <- parseLDIFFile src+ ml2 <- parseLDIFFile dst case rights [ml1,ml2] of [l1,l2] -> case diffLDIF l1 l2 of Left err -> putStrLn err
src/ldifmodify.hs view
@@ -16,21 +16,18 @@ , modFiles :: [FilePath] , outFile :: FilePath } deriving (Show, Data, Typeable) -defaultCfg = mode $ LdifModify { baseFile = def &= typFile & flag "f" & text "Base LDIF File"- , modFiles = def &= args & typ "LDIF Files for applying"- , outFile = def &= typFile & flag "o" & text "Output LDIF File" }--verifyCfg :: LdifModify -> IO ()-verifyCfg (LdifModify [] [] []) = do- msg <- cmdArgsHelp progDesc [defaultCfg] Text- error msg-verifyCfg (LdifModify bf mfx ouf) | length bf == 0 = error "Missing Base LDIF File parameter (-f)"- | length mfx == 0 = error "Missing LDIF Files for applying as arguments"- | otherwise = return () +defaultCfg = LdifModify { baseFile = def &= typFile &= name "f" &= help "Base LDIF File"+ , modFiles = def &= args &= typ "LDIF Files for applying"+ , outFile = def &= typFile &= name "o" &= help "Output LDIF File" } main = do- cfg <- cmdArgs progDesc [defaultCfg]- verifyCfg cfg+ cfg <- cmdArgs defaultCfg+ execute cfg++execute (LdifModify [] _ _) = putStrLn "Error: -f base LDIF File is mandatory"+execute (LdifModify _ [] _) = putStrLn "Error: no LDIF Files for applying provided"+execute (LdifModify _ _ []) = putStrLn "Error: -o output LDIF File is mandatory"+execute cfg = do baseLDIF <- safeParseLDIFFile (baseFile cfg) modLDIFs <- mapM (safeParseLDIFFile) (modFiles cfg) let outLDIF = foldr (flip applyLDIF) baseLDIF modLDIFs