packages feed

steeloverseer 1.1.0.6 → 1.1.1.0

raw patch · 4 files changed

+40/−76 lines, 4 filesdep +ansi-terminaldep +filepathdep −system-filepathdep −textdep ~fsnotify

Dependencies added: ansi-terminal, filepath

Dependencies removed: system-filepath, text

Dependency ranges changed: fsnotify

Files

− src/ANSIColors.hs
@@ -1,39 +0,0 @@-module ANSIColors where--data ANSIColor = ANSIBlack | ANSIRed | ANSIGreen | ANSIYellow | ANSIBlue | ANSIMagenta | ANSICyan | ANSIWhite | ANSINone-    deriving (Ord, Eq)--instance Show ANSIColor where-    show ANSINone = "\27[0m" -    show c = "\27[" ++ show cn ++ "m"-        where cn = 30 + colorNum c --colorNum :: ANSIColor -> Int-colorNum c = length $ takeWhile (/= c) ansibow --ansibow :: [ANSIColor]-ansibow = [ ANSIBlack-          , ANSIRed-          , ANSIGreen-          , ANSIYellow-          , ANSIBlue-          , ANSIMagenta-          , ANSICyan-          , ANSIWhite -          ]--colorString :: ANSIColor -> String -> String-colorString c s = show c ++ s ++ show ANSINone --greenPrint :: (Show a) => a -> IO ()-greenPrint = colorPrint ANSIGreen--cyanPrint :: (Show a) => a -> IO ()-cyanPrint = colorPrint ANSICyan --redPrint :: (Show a) => a -> IO ()-redPrint = colorPrint ANSIRed --colorPrint :: (Show a) => ANSIColor -> a -> IO ()-colorPrint c = putStrLn . colorString c . show-
src/Main.hs view
@@ -3,11 +3,7 @@  import System.Environment        (getArgs) import System.Console.GetOpt-import Data.List import Control.Monad-import Filesystem.Path.CurrentOS hiding (concat, null)-import Data.Text as T            hiding (foldl, concat, intercalate, null)-import Prelude                   hiding (FilePath) import SOS  main :: IO ()@@ -28,7 +24,7 @@ defaultOptions = Options { optShowVersion = False                          , optCommands    = []                          , optPatterns    = []-                         , optDirectory   = fromText $ T.pack "."+                         , optDirectory   = "."                          }  options :: [OptDescr (Options -> Options)]@@ -42,7 +38,7 @@               (ReqArg (\e opts -> opts { optPatterns = optPatterns opts ++ [e] }) "pattern")               "Add pattern to match on file path."           , Option "d" ["directory"]-              (ReqArg (\d opts -> opts { optDirectory = decodeString d }) "directory")+              (ReqArg (\d opts -> opts { optDirectory = d }) "directory")               "Set directory to watch for changes (default is ./)."           ] 
src/SOS.hs view
@@ -1,18 +1,15 @@-{-# LANGUAGE OverloadedStrings #-} module SOS where --import           ANSIColors-import           System.FSNotify-import           System.Process-import           System.Exit-import           Control.Monad-import           Control.Concurrent-import           Data.Maybe-import           Text.Regex.TDFA-import           Filesystem.Path.CurrentOS as OS-import           Prelude hiding   ( FilePath )-import qualified Data.Text as T+import  System.FSNotify+import  System.Process+import  System.Exit+import  System.FilePath+import  System.Console.ANSI+import  Control.Monad+import  Control.Concurrent+import  Data.Maybe+import  Text.Regex.TDFA+import  Prelude hiding   ( FilePath )  -- | A structure to hold our changed file events, -- list of commands to run and possibly the currently running process,@@ -47,16 +44,8 @@     stopManager wm  actionPredicateForRegexes :: [String] -> Event -> Bool-actionPredicateForRegexes ptns event = or (fmap (filepath =~) ptns :: [Bool])-    where filepath = case toText $ eventPath event of-                         Left f  -> T.unpack f-                         Right f -> T.unpack f--actionPredicateForExts :: [String] -> Event -> Bool-actionPredicateForExts exts event = let maybeExt = extension $ eventPath event in-    case fmap T.unpack maybeExt of-        Just ext -> ext `elem` exts-        Nothing  -> False+actionPredicateForRegexes ptns event =+    or (fmap (eventPath event =~) ptns :: [Bool])  performCommand :: MVar SOSState -> [String] -> Event -> IO () performCommand mvar cmds event = do@@ -90,7 +79,12 @@  startWriteProcess mvar (cmd:cmds) delay = void $ forkIO $ do     threadDelay delay-    putStrLn $ colorString ANSIGreen "\n> " ++ cmd ++ "\n"++    setSGR [SetColor Foreground Dull Green]+    putStr "\n> "+    setSGR [Reset]+    putStrLn cmd+     pId <- runCommand cmd     mEvProcCurrent <- tryTakeMVar mvar     case mEvProcCurrent of@@ -109,5 +103,19 @@ terminatePID :: ProcessHandle -> IO () terminatePID pid = do     terminateProcess pid-    putStrLn $ colorString ANSIRed "Terminated hanging process."+    putStrLnColor Red "Terminated hanging process." +cyanPrint :: Show a => a -> IO ()+cyanPrint = putStrLnColor Cyan . show++redPrint :: Show a => a -> IO ()+redPrint = putStrLnColor Red . show++greenPrint :: Show a => a -> IO ()+greenPrint = putStrLnColor Green . show++putStrLnColor :: Color -> String -> IO ()+putStrLnColor c s = do+    setSGR [SetColor Foreground Dull c]+    putStrLn s+    setSGR [Reset]
steeloverseer.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/  name:                steeloverseer-version:             1.1.0.6+version:             1.1.1.0 synopsis:            A file watcher. description:         A command line tool that responds to filesystem events. Allows the user to automatically execute commands after files are added or updated. Watches files using regular expressions. license:             BSD3@@ -25,13 +25,12 @@   ghc-options:         -Wall -threaded   hs-source-dirs:      src   main-is:             Main.hs-  other-modules:       SOS, ANSIColors+  other-modules:       SOS   build-depends:       base >=4.5 && <4.9,-                       fsnotify >=0.0.11,-                       system-filepath >=0.4.7,+                       fsnotify >=0.2 && < 0.3,+                       filepath >= 1.4 && < 1.5,+                       ansi-terminal >= 0.6 && < 0.7,                        process >= 1.1.0.2,-                       text >=0.11.2.3,                        time >=1.4,                        regex-tdfa >=1.1.8,                        unix >=2.6.0.1-