Created
February 21, 2018 10:36
-
-
Save matsubara0507/909052340bf8a7a04de1cde11fc3f787 to your computer and use it in GitHub Desktop.
brittany を再帰的にかける
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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