Skip to content

Instantly share code, notes, and snippets.

@matsubara0507
Created February 21, 2018 10:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsubara0507/909052340bf8a7a04de1cde11fc3f787 to your computer and use it in GitHub Desktop.
Save matsubara0507/909052340bf8a7a04de1cde11fc3f787 to your computer and use it in GitHub Desktop.
brittany を再帰的にかける
-- stack script --resolver lts-10.6 -- .\.temp\brittany-all.hs src --write-mode inplace
{-# LANGUAGE OverloadedStrings #-}
module Main where
import Data.Text (Text, pack)
import qualified Filesystem.Path as P
import Shelly
import System.Environment (getArgs)
main :: IO ()
main = do
(path:opts) <- fmap pack <$> getArgs
shelly $ do
files <- lsRhs $ fromText path
mapM_ (`brittany` opts) files
brittany :: P.FilePath -> [Text] -> Sh ()
brittany path opts =
run_ "brittany" (opts ++ [toTextIgnore path])
lsRhs :: P.FilePath -> Sh [P.FilePath]
lsRhs path
| hasExt "hs" path = pure [path]
| otherwise = (fmap mconcat . mapM lsRhs) =<< ls path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment