git.iko.soy/rowtype-yoga/purescript-native
on golang help sign in
Globs for all
commit8e7adc3ee2dd534d91062553d2c931538d3505d5 authorPhil Freeman <paf31@cantab.net> dateWed 10 Jun 2015, 17:12 (11 years ago) parentd157632
3 files changed+16−9
hierarchy/Main.hs+9−5 psc-docs/Main.hs+3−1 purescript.cabal+4−3
hierarchy/Main.hs+9−5
@@ -13,6 +13,8 @@
1313--
1414-----------------------------------------------------------------------------
1515
16+{-# LANGUAGE TupleSections #-}
17+
1618module Main where
1719
1820import Control.Monad (unless)
@@ -24,6 +26,7 @@ import Data.Version (showVersion)
2426import Options.Applicative
2527import System.Directory (createDirectoryIfMissing)
2628import System.FilePath ((</>))
29+import System.FilePath.Glob (glob)
2730import System.Exit (exitFailure, exitSuccess)
2831import System.IO (hPutStr, stderr)
2932
@@ -50,13 +53,14 @@ instance Ord SuperMap where
5053runModuleName :: P.ModuleName -> String
5154runModuleName (P.ModuleName pns) = intercalate "_" (P.runProperName `map` pns)
5255
53−readInput :: FilePath -> IO (Either P.MultipleErrors [P.Module])
54−readInput filename = do
55− content <- readFile filename
56− return $ map snd <$> P.parseModulesFromFiles id [(filename, content)]
56+readInput :: [FilePath] -> IO (Either P.MultipleErrors [P.Module])
57+readInput paths = do
58+ content <- mapM (\path -> (path, ) <$> readFile path) paths
59+ return $ map snd <$> P.parseModulesFromFiles id content
5760
5861compile :: HierarchyOptions -> IO ()
59−compile (HierarchyOptions input mOutput) = do
62+compile (HierarchyOptions inputGlob mOutput) = do
63+ input <- glob inputGlob
6064 modules <- readInput input
6165 case modules of
6266 Left errs -> hPutStr stderr (P.prettyPrintMultipleErrors False errs) >> exitFailure
psc-docs/Main.hs+3−1
@@ -34,6 +34,7 @@ import System.Exit (exitFailure)
3434import System.IO (hPutStrLn, stderr)
3535import System.Directory (createDirectoryIfMissing)
3636import System.FilePath (takeDirectory)
37+import System.FilePath.Glob (glob)
3738
3839import Etags
3940import Ctags
@@ -61,7 +62,8 @@ data PSCDocsOptions = PSCDocsOptions
6162 deriving (Show)
6263
6364docgen :: PSCDocsOptions -> IO ()
64−docgen (PSCDocsOptions fmt input output) =
65+docgen (PSCDocsOptions fmt inputGlob output) = do
66+ input <- concat <$> mapM glob inputGlob
6567 case fmt of
6668 Etags -> dumpTags input dumpEtags
6769 Ctags -> dumpTags input dumpCtags
purescript.cabal+4−3
@@ -185,8 +185,8 @@ executable psci
185185executable psc-docs
186186 build-depends: base >=4 && <5, purescript -any,
187187 optparse-applicative >= 0.10.0, process -any, mtl -any,
188− split -any, ansi-wl-pprint -any, directory -any, filepath
189− -any
188+ split -any, ansi-wl-pprint -any, directory -any,
189+ filepath -any, Glob -any
190190 main-is: Main.hs
191191 buildable: True
192192 hs-source-dirs: psc-docs
@@ -213,7 +213,8 @@ executable psc-publish
213213
214214executable psc-hierarchy
215215 build-depends: base >=4 && <5, purescript -any, optparse-applicative >= 0.10.0,
216− process -any, mtl -any, parsec -any, filepath -any, directory -any
216+ process -any, mtl -any, parsec -any, filepath -any, directory -any,
217+ Glob -any
217218 main-is: Main.hs
218219 buildable: True
219220 hs-source-dirs: hierarchy