Skip to content

Commit 8e7adc3

Browse files
committed
Globs for all
1 parent d157632 commit 8e7adc3

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

hierarchy/Main.hs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
--
1414
-----------------------------------------------------------------------------
1515

16+
{-# LANGUAGE TupleSections #-}
17+
1618
module Main where
1719

1820
import Control.Monad (unless)
@@ -24,6 +26,7 @@ import Data.Version (showVersion)
2426
import Options.Applicative
2527
import System.Directory (createDirectoryIfMissing)
2628
import System.FilePath ((</>))
29+
import System.FilePath.Glob (glob)
2730
import System.Exit (exitFailure, exitSuccess)
2831
import System.IO (hPutStr, stderr)
2932

@@ -50,13 +53,14 @@ instance Ord SuperMap where
5053
runModuleName :: P.ModuleName -> String
5154
runModuleName (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

5861
compile :: 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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import System.Exit (exitFailure)
3434
import System.IO (hPutStrLn, stderr)
3535
import System.Directory (createDirectoryIfMissing)
3636
import System.FilePath (takeDirectory)
37+
import System.FilePath.Glob (glob)
3738

3839
import Etags
3940
import Ctags
@@ -61,7 +62,8 @@ data PSCDocsOptions = PSCDocsOptions
6162
deriving (Show)
6263

6364
docgen :: 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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ executable psci
185185
executable 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

214214
executable 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

0 commit comments

Comments
 (0)