zifter-hindent 0.0.0.0 → 0.0.0.1
raw patch · 2 files changed
+29/−20 lines, 2 filesdep ~zifterPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: zifter
API changes (from Hackage documentation)
+ Zifter.Hindent: HindentBin :: (Path Abs File) -> HindentBin
+ Zifter.Hindent: getHindent :: Zift HindentBin
+ Zifter.Hindent: hindentCmd :: HindentBin -> [String] -> String
+ Zifter.Hindent: instance GHC.Classes.Eq Zifter.Hindent.HindentBin
+ Zifter.Hindent: instance GHC.Show.Show Zifter.Hindent.HindentBin
+ Zifter.Hindent: newtype HindentBin
- Zifter.Hindent: hindentCheckAndPrintVersion :: Zift ()
+ Zifter.Hindent: hindentCheckAndPrintVersion :: HindentBin -> Zift ()
- Zifter.Hindent: hindentSingleSource :: Path Abs File -> Zift ()
+ Zifter.Hindent: hindentSingleSource :: HindentBin -> Path Abs File -> Zift ()
Files
- src/Zifter/Hindent.hs +24/−16
- zifter-hindent.cabal +5/−4
src/Zifter/Hindent.hs view
@@ -1,7 +1,6 @@ module Zifter.Hindent where import Control.Monad.IO.Class-import Data.Foldable import Path import Path.IO import Safe@@ -12,17 +11,31 @@ import Zifter.Zift +newtype HindentBin =+ HindentBin (Path Abs File)+ deriving (Show, Eq)+ hindentZift :: Zift () hindentZift = do- () <- hindentCheckAndPrintVersion+ hindentBin <- getHindent+ () <- hindentCheckAndPrintVersion hindentBin rd <- getRootDir fs <- liftIO $ snd <$> listDirRecur rd let sources = filter (not . hidden) $ filter ((== ".hs") . fileExtension) fs- for_ sources hindentSingleSource+ forZ_ sources $ hindentSingleSource hindentBin -hindentCheckAndPrintVersion :: Zift ()-hindentCheckAndPrintVersion = do- let cmd = "hindent --version"+getHindent :: Zift HindentBin+getHindent = do+ home <- liftIO getHomeDir+ file <- liftIO $ parseRelFile ".local/bin/hindent"+ pure $ HindentBin $ home </> file++hindentCmd :: HindentBin -> [String] -> String+hindentCmd (HindentBin ap) args = unwords $ toFilePath ap : args++hindentCheckAndPrintVersion :: HindentBin -> Zift ()+hindentCheckAndPrintVersion hb = do+ let cmd = hindentCmd hb ["--version"] (_, mouth, _, ph) <- liftIO $ createProcess ((shell cmd) {std_out = CreatePipe}) ec <- liftIO $ waitForProcess ph@@ -33,17 +46,12 @@ ExitFailure c -> fail $ unwords [cmd, "failed with exit code", show c] ExitSuccess -> pure () -hindentSingleSource :: Path Abs File -> Zift ()-hindentSingleSource file = do+hindentSingleSource :: HindentBin -> Path Abs File -> Zift ()+hindentSingleSource hb file = do let cmd =- unwords- [ "hindent"- , "--indent-size"- , "4"- , "--line-length"- , "80"- , toFilePath file- ]+ hindentCmd+ hb+ ["--indent-size", "4", "--line-length", "80", toFilePath file] let cp = shell cmd ec <- liftIO $ do
zifter-hindent.cabal view
@@ -1,7 +1,5 @@ name: zifter-hindent-synopsis: zifter-hindent-description: zifter-hindent-version: 0.0.0.0+version: 0.0.0.1 cabal-version: >=1.10 build-type: Simple license: MIT@@ -9,6 +7,9 @@ copyright: Copyright: (c) 2017 Tom Sydney Kerckhove maintainer: syd.kerckhove@gmail.com homepage: http://cs-syd.eu+synopsis: zifter-hindent+description:+ zifter-hindent category: Zift author: Tom Sydney Kerckhove @@ -20,7 +21,7 @@ process -any, filepath >=1.4 && <1.5, directory -any,- zifter >=0.0 && <0.1,+ zifter >=0.0.1.2 && <0.1, path >=0.5 && <0.6, path-io >=1.2 && <1.3, safe >=0.3 && <0.4