packages feed

multifile 0.1.0.0 → 0.1.0.1

raw patch · 2 files changed

+35/−5 lines, 2 filesdep +directorydep +optparse-applicative

Dependencies added: directory, optparse-applicative

Files

multifile.cabal view
@@ -10,7 +10,7 @@ -- PVP summary:      +-+------- breaking API changes --                   | | +----- non-breaking API additions --                   | | | +--- code changes with no API change-version:             0.1.0.0+version:             0.1.0.1  -- A short (one-line) description of the package. synopsis: create many files from one@@ -60,7 +60,7 @@   -- other-extensions:          -- Other library packages from which modules are imported.-  build-depends:       base >=4.9 && <4.10 , HaXml < 10000+  build-depends:       base >=4.9 && <4.10 , HaXml < 10000 , directory < 10000, optparse-applicative      -- Directories containing source files.   hs-source-dirs:      src
src/Main.hs view
@@ -2,15 +2,45 @@  import System.Environment import System.IO+import Text.XML.HaXml import Text.XML.HaXml.XmlContent.Haskell+  import Extsubset import Data.Either+import Control.Monad+import System.Directory +import Options.Applicative+++create' xs = do+ files <- forM xs $ \filePath -> do+   content <- readFile filePath+   return ( File (File_Attrs filePath) content )+ return (show $ htmlprint $ toContents $ Multifile files)++create xs = create' xs >>= putStr++ -- data Args = Args {++dir x = getDirectoryContents x >>= create + main :: IO () main = do -       x <- getContents    -       let p = (readXml x :: Either String Multifile)-       either print processFiles p+       args <- getArgs+       case args of +         [] -> do+           x <- getContents    +           let p = (readXml x :: Either String Multifile)+           either print processFiles p+         x -> z x+ where + z ("-create":xs) = create xs+ z ("-c":xs) = create xs+ z ("-dir":x:[]) = dir x+ z _             = putStr "unknown usage"  processFiles (Multifile xs) = mapM_ processFile xs processFile (File (File_Attrs path) content) = writeFile path content++