packages feed

ghcid 0.4 → 0.4.1

raw patch · 4 files changed

+29/−20 lines, 4 filesdep ~extraPVP ok

version bump matches the API change (PVP)

Dependency ranges changed: extra

API changes (from Hackage documentation)

Files

CHANGES.txt view
@@ -1,5 +1,8 @@ Changelog for GHCiD +0.4.1+    #37, add a --notitle flag+    Require extra-1.2 0.4     #33, make Ctrl-C more robust     #31, add an outputfile feature
ghcid.cabal view
@@ -1,7 +1,7 @@ cabal-version:      >= 1.10 build-type:         Simple name:               ghcid-version:            0.4+version:            0.4.1 license:            BSD3 license-file:       LICENSE category:           Development@@ -30,7 +30,7 @@         filepath,         time,         directory,-        extra >= 1.1,+        extra >= 1.2,         process >= 1.1,         cmdargs >= 0.10,         terminal-size >= 0.3@@ -54,7 +54,7 @@       directory,       containers,       fsnotify,-      extra >= 1.1,+      extra >= 1.2,       process >= 1.1,       cmdargs >= 0.10,       ansi-terminal,@@ -79,7 +79,7 @@     process,     containers,     fsnotify,-    extra >= 1.1,+    extra >= 1.2,     ansi-terminal,     terminal-size >= 0.3,     cmdargs,
src/Ghcid.hs view
@@ -7,7 +7,6 @@ import Control.Applicative import Control.Monad.Extra import Control.Concurrent.Extra-import Control.Exception import Data.List.Extra import Data.Maybe import Data.Tuple.Extra@@ -36,6 +35,7 @@     ,height :: Maybe Int     ,width :: Maybe Int     ,topmost :: Bool+    ,notitle :: Bool     ,restart :: [FilePath]     ,directory :: FilePath     ,outputfile :: [FilePath]@@ -49,6 +49,7 @@     ,height = Nothing &= help "Number of lines to show (defaults to console height)"     ,width = Nothing &= help "Number of columns to show (defaults to console width)"     ,topmost = False &= name "t" &= help "Set window topmost (Windows only)"+    ,notitle = False &= help "Don't update the shell title"     ,restart = [] &= typFile &= help "Restart the command if any of these files change (defaults to .ghci or .cabal)"     ,directory = "." &= typDir &= name "C" &= help "Set the current directory"     ,outputfile = [] &= typFile &= name "o" &= help "File to write the full output to"@@ -62,16 +63,19 @@     | otherwise = do         files <- getDirectoryContents "."         let cabal = filter ((==) ".cabal" . takeExtension) files-        if null cabal || ".ghci" `elem` files-            then return o{command="ghci", restart=[".ghci"]}-            else return o{command="cabal repl", restart=cabal}+        let useGhci = o{command="ghci", restart=[".ghci"]}+        let useCabal = o{command="cabal repl", restart=cabal}+        let useStack = o{command="stack ghci", restart=cabal ++ ["stack.yaml"]}+        return $ case () of+            _ | ".ghci" `elem` files -> useGhci+              | "stack.yaml" `elem` files, False -> useStack -- see #130+              | cabal /= [] -> useCabal+              | otherwise -> useGhci  +-- ensure the action runs off the main thread ctrlC :: IO () -> IO ()-ctrlC act = do-    bar <- newBarrier-    forkFinally act $ signalBarrier bar-    either throwIO return =<< waitBarrier bar+ctrlC = join . onceFork   main :: IO ()@@ -91,7 +95,7 @@                 -- so putStrLn width 'x' uses up two lines                 return (f width 80 (pred . fst), f height 8 snd)         withWaiterNotify $ \waiter ->-            runGhcid waiter restart command outputfile test height $ \xs -> do+            runGhcid waiter restart command outputfile test height (not notitle) $ \xs -> do                 outWith $ forM_ (groupOn fst xs) $ \x@((s,_):_) -> do                     when (s == Bold) $ setSGR [SetConsoleIntensity BoldIntensity]                     putStr $ concatMap ((:) '\n' . snd) x@@ -102,8 +106,8 @@ data Style = Plain | Bold deriving Eq  -runGhcid :: Waiter -> [FilePath] -> String -> [FilePath] -> Maybe String -> IO (Int,Int) -> ([(Style,String)] -> IO ()) -> IO ()-runGhcid waiter restart command outputfiles test size output = do+runGhcid :: Waiter -> [FilePath] -> String -> [FilePath] -> Maybe String -> IO (Int,Int) -> Bool -> ([(Style,String)] -> IO ()) -> IO ()+runGhcid waiter restart command outputfiles test size titles output = do     let outputFill :: Maybe [Load] -> [String] -> IO ()         outputFill load msg = do             (width, height) <- size@@ -114,7 +118,7 @@             output $ load ++ map (Plain,) msg ++ replicate (height - (length load + length msg)) (Plain,"")      restartTimes <- mapM getModTime restart-    outputFill Nothing ["Loading..."]+    outputFill Nothing ["Loading " ++ command ++ "..."]     nextWait <- waitFiles waiter     (ghci,messages) <- startGhci command Nothing     curdir <- getCurrentDirectory@@ -137,7 +141,7 @@             let (countErrors, countWarnings) = both sum $ unzip [if loadSeverity m == Error then (1,0) else (0,1) | m@Message{} <- messages]             test <- return $ if countErrors == 0 then test else Nothing -            let updateTitle extra = setTitle $+            let updateTitle extra = when titles $ setTitle $                     let f n msg = if n == 0 then "" else show n ++ " " ++ msg ++ ['s' | n > 1]                     in (if countErrors == 0 && countWarnings == 0 then allGoodMessage else f countErrors "error" ++                         (if countErrors > 0 && countWarnings > 0 then ", " else "") ++ f countWarnings "warning") ++@@ -166,7 +170,7 @@                 fire nextWait messages warnings             else do                 stopGhci ghci-                runGhcid waiter restart command outputfiles test size output+                runGhcid waiter restart command outputfiles test size titles output      fire nextWait messages [] 
src/Test/Polling.hs view
@@ -44,7 +44,7 @@         try_ $ system "chmod og-w . .ghci"          withWaiterPoll $ \waiter -> bracket (-          forkIO $ runGhcid waiter [] "ghci" [] Nothing (return (100, 50)) $ \msg ->+          forkIO $ runGhcid waiter [] "ghci" [] Nothing (return (100, 50)) False $ \msg ->             unless (isLoading $ map snd msg) $ putMVarNow ref $ map snd msg           ) killThread $ \_ -> do             require requireAllGood@@ -52,7 +52,9 @@             outStrLn "\nSuccess"  isLoading :: [String] -> Bool-isLoading xs = listToMaybe xs `elem` [Just "Reloading...",Just "Loading..."]+isLoading ("Reloading...":_) = True+isLoading (x:_) | "Loading" `isPrefixOf` x && "..." `isSuffixOf` x = True+isLoading _ = False  putMVarNow :: MVar a -> a -> IO () putMVarNow ref x = do