packages feed

trackit 0.7.3 → 0.8

raw patch · 5 files changed

+51/−20 lines, 5 filesdep +Globdep +directorydep +filepathdep ~brickdep ~fsnotifydep ~mtl

Dependencies added: Glob, directory, filepath

Dependency ranges changed: brick, fsnotify, mtl, optparse-generic, text, vty

Files

LICENSE view
@@ -1,4 +1,4 @@-Copyright (c) 2018-2019, Emil Axelsson+Copyright (c) 2018-2025, Emil Axelsson  All rights reserved. 
README.md view
@@ -15,6 +15,10 @@     > GIT_DIR=`git rev-parse --git-dir`     > trackit --watch-tree=$GIT_DIR --command="git log --graph --all --oneline --decorate --color" +Ignore temporary files or directories using glob patterns:++    > trackit --watch-tree=. --exclude '**/*.tmp' --command="ls --color"+ ## Installation  `trackit` can be installed from [Hackage](https://hackage.haskell.org/package/trackit) using Cabal:
src/Main.hs view
@@ -20,11 +20,14 @@ import qualified Data.Text as Text import qualified Data.Text.Lazy as LText import GHC.Generics (Generic)+import System.Directory (canonicalizePath) import System.Exit (exitSuccess)+import System.FilePath (isRelative, makeRelative, splitDirectories) import System.IO (BufferMode (..)) import qualified System.Process.ListLike as Process import qualified System.Process.Text as Text +import qualified System.FilePath.Glob as Glob import System.FSNotify (eventTime, withManager) import qualified System.FSNotify as FSNotify @@ -41,12 +44,13 @@ type LText = LText.Text  data CmdOptions = CmdOptions-  { _watchDir      :: [FilePath]   <?> "Directory to watch for changes in (not sub-directories). Cannot be used together with '--watch-tree'."-  , _watchTree     :: [FilePath]   <?> "Directory tree to watch for changes in (including sub-directories). Cannot be used together with '--watch-dir'."+  { _watchDir      :: [FilePath]   <?> "Directory to watch for changes in (not sub-directories). This option can be repeated. Cannot be used together with '--watch-tree'."+  , _watchTree     :: [FilePath]   <?> "Directory tree to watch for changes in (including sub-directories). This option can be repeated. Cannot be used together with '--watch-dir'."   , _command       :: Maybe String <?> "Command to run"+  , _exclude       :: [FilePath]   <?> "Glob pattern for files/directories to ignore. The pattern is relative to the watched directory. Use double quotes to avoid glob expansion in the shell (e.g. -x \"src/*\"). This option can be repeated."   , _followTail    :: Bool         <?> "Follow the tail of the generated output."   , _showRunning   :: Bool         <?> "Display a message while the command is running."-  , _incremental   :: Bool         <?> "Allow output to be updated incrementally. Redraws the buffer for every output line, so should only be used for \+  , _incremental   :: Bool         <?> "Allow output to be updated incrementally. Re-draws the buffer for every output line, so should only be used for \                                        \slow outputs. Implies '--show-running'."   , _stabilization :: Maybe Int    <?> "Minimal time (milliseconds) between any file event and the next command update (default: 200)"   , _version       :: Bool         <?> "Print the version number."@@ -61,6 +65,7 @@ shortName "_watchDir" = Just 'd' shortName "_watchTree" = Just 't' shortName "_showRunning" = Just 'r'+shortName "_exclude" = Just 'x' shortName "_debug" = Just 'g' shortName (_:c:_) = Just c shortName _ = Nothing@@ -86,6 +91,7 @@              incremental   = unHelpful _incremental              stabPerMs     = fromMaybe 200 $ unHelpful _stabilization              stabilization = fromIntegral stabPerMs / 1000+             excludePatterns = unHelpful _exclude              debug         = unHelpful _debug           in Options {..} @@ -194,15 +200,32 @@   updReq   <- newTVarIO (Just UpdateRequest)   -- Channel for GUI update events   updEv    <- newBChan 1+  watchDirsAbs <- mapM (\(path, depth) -> (, depth) <$> canonicalizePath path) watchDirs   let mkUpdReq      = atomically $ writeTVar updReq (Just UpdateRequest)       setFsEvent ev = atomically $ writeTVar lastFSEv $ Just ev+      excludeGlobs  = map Glob.compile excludePatterns+      shouldNotify base ev =+        case excludeGlobs of+          [] -> True+          _  ->+            let evPath = FSNotify.eventPath ev+                relPath = makeRelative base evPath+                isOutside =+                  case splitDirectories relPath of+                    ("..":_) -> True+                    _        -> False+                matchPath =+                  if isRelative relPath && not isOutside+                    then relPath+                    else evPath+             in not (any (`Glob.match` matchPath) excludeGlobs)   tid <- forkIO $ worker opts lastFSEv updReq (updater opts updEv)    void $ withManager $ \m -> do-    forM_ watchDirs $ \(path, depth) ->+    forM_ watchDirsAbs $ \(path, depth) ->       void $ case depth of-        Single    -> FSNotify.watchDir  m path (const True) setFsEvent-        Recursive -> FSNotify.watchTree m path (const True) setFsEvent+        Single    -> FSNotify.watchDir  m path (shouldNotify path) setFsEvent+        Recursive -> FSNotify.watchTree m path (shouldNotify path) setFsEvent     appMain opts mkUpdReq updEv    killThread tid
src/Options.hs view
@@ -15,5 +15,6 @@   , showRunning   :: Bool   , incremental   :: Bool   , stabilization :: NominalDiffTime+  , excludePatterns :: [FilePath]   , debug         :: Bool   } deriving (Show, Generic)
trackit.cabal view
@@ -1,5 +1,5 @@ name:                trackit-version:             0.7.3+version:             0.8 synopsis:            A command-line tool for live monitoring description:         @trackit@ is a command-line tool that listens for changes                      in a user-supplied directory. Whenever there is a change,@@ -23,7 +23,7 @@ license-file:        LICENSE author:              Emil Axelsson maintainer:          78emil@gmail.com-copyright:           2018-2019 Emil Axelsson+copyright:           2018-2025 Emil Axelsson homepage:            https://github.com/emilaxelsson/trackit bug-reports:         https://github.com/emilaxelsson/trackit/issues category:            Development@@ -42,19 +42,22 @@                         Options                         ParseANSI                         TUI-  build-depends:        base <5-                      , brick >= 1.0 && == 1.1+  build-depends:        base < 5+                      , brick >= 1.0 && == 1.10                           -- EventM was refactored in 1.0-                      , fsnotify <0.4-                      , microlens-platform <0.5-                      , mtl <2.3-                      , optparse-generic >=1.2 && < 1.5-                      , process <1.7-                      , process-extras >=0.4 && <0.8-                      , stm <2.6-                      , text <1.3+                      , directory < 1.4+                      , filepath < 1.6+                      , fsnotify < 0.5+                      , Glob < 0.11+                      , microlens-platform < 0.5+                      , mtl < 2.4+                      , optparse-generic >= 1.2 && < 1.6+                      , process < 1.7+                      , process-extras >= 0.4 && < 0.8+                      , stm < 2.6+                      , text < 2.1                       , time < 1.13-                      , vty < 5.37+                      , vty < 5.40   hs-source-dirs:       src   default-language:     Haskell2010   default-extensions:   BangPatterns