packages feed

fswait 1.0.0 → 1.1.0

raw patch · 2 files changed

+15/−10 lines, 2 filesdep ~optparse-applicativedep ~optparse-genericdep ~text

Dependency ranges changed: optparse-applicative, optparse-generic, text, turtle

Files

fswait.cabal view
@@ -1,5 +1,5 @@ name:                fswait-version:             1.0.0+version:             1.1.0 synopsis:            Wait and observe events on the filesystem for a path, with a timeout homepage:            https://github.com/ixmatus/fswait Bug-Reports:         https://github.com/ixmatus/fswait/issues@@ -31,10 +31,10 @@   ghc-options:         -Wall -threaded -rtsopts -with-rtsopts=-N   build-depends:                 base                 >= 4.8     && < 5-              , optparse-generic     >= 1.1.5   && < 1.2-              , optparse-applicative >= 0.12    && < 0.14+              , optparse-generic     >= 1.2     && < 1.3+              , optparse-applicative >= 0.12    && < 0.15               , system-filepath      >= 0.3.1   && < 0.5-              , turtle               >= 1.2.8   && < 1.3+              , turtle               >= 1.3.0   && < 1.4               , time-units           >= 1.0.0   && < 2.0               , stm                  >= 2.4.4.1 && < 2.5               , hinotify             >= 0.3     && < 0.4
src/Main.hs view
@@ -30,6 +30,7 @@ import qualified System.Timeout import           Turtle                       (ExitCode (..), fp, s, void, (%)) import qualified Turtle+import qualified Turtle.Line  data Options w = Options   { timeout :: w ::: Maybe Time.Units.Second <?> "Window to observe a filesystem event (default: 120s, negative values wait indefinitely)"@@ -45,10 +46,11 @@   parseRecord = fmap getOnly parseRecord instance ParseFields Time.Units.Second instance ParseField Time.Units.Second where-  parseField h n =+  parseField h n c =     fmap (Time.Units.fromMicroseconds . (*μ))       (Options.option Options.auto $        (  Options.metavar "Seconds"+       <> foldMap  Options.short               c        <> foldMap (Options.long . Text.unpack) n        <> foldMap (Options.help . Text.unpack) h        )@@ -59,7 +61,7 @@   parseRecord = fmap getOnly parseRecord instance ParseFields EventVariety instance ParseField EventVariety where-  parseField _ _ =+  parseField _ _ _ =         Options.flag' Access       (Options.long "access")     <|> Options.flag' Modify       (Options.long "modify")     <|> Options.flag' Attrib       (Options.long "attrib")@@ -89,7 +91,8 @@   when exists $ do     pathExists <- Turtle.testfile path     when pathExists $ do-      Turtle.err $ Turtle.format ("exists: "%fp) path+      let msg = Turtle.format ("exists: "%fp) path+      mapM_ Turtle.err (Turtle.Line.textToLines msg)       Turtle.exit ExitSuccess    mvar <- STM.atomically TMVar.newEmptyTMVar@@ -118,11 +121,13 @@             | otherwise               -> empty -  Turtle.err $ Turtle.format ("observing "%s%" for "%fp) eventsStr path+  let msg0 = Turtle.format ("observing "%s%" for "%fp) eventsStr path+  mapM_ Turtle.err (Turtle.Line.textToLines msg0)    let timeoutWindow | timeout' > 0 = Text.pack (show timeout')                     | otherwise    = "indefinite"-  Turtle.err $ Turtle.format ("the window for an observation is "%s) timeoutWindow+  let msg1 = Turtle.format ("the window for an observation is "%s) timeoutWindow+  mapM_ Turtle.err (Turtle.Line.textToLines msg1)    let doWatch =         withINotify (\i -> do@@ -145,4 +150,4 @@    (fromIntegral $ Time.Units.toMicroseconds timeout')    doWatch >>= \case     Nothing -> Turtle.exit (ExitFailure 1)-    Just ev -> Turtle.echo (Text.pack $ show ev)+    Just ev -> mapM_ Turtle.echo (Turtle.Line.textToLines (Text.pack $ show ev))