-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0e768e0
commit a6f35ef
Showing
5 changed files
with
3,079 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Path | ||
import qualified Data.ByteString.Lazy as BS | ||
import qualified Data.Text as T | ||
import Data.Attoparsec.Text (parseOnly, endOfInput, eitherP) | ||
import Data.Attoparsec.Path (absFilePath, relFilePath, absDirPath) | ||
import System.INotify (initINotify, removeWatch, killINotify) | ||
import System.File.Follow (follow) | ||
import System.Directory (getCurrentDirectory) | ||
import System.Environment (getArgs) | ||
import Control.Monad (forever) | ||
import Control.Exception (bracket) | ||
import Control.Concurrent (threadDelay) | ||
|
||
|
||
main = do | ||
[f] <- getArgs | ||
f <- case parseOnly (eitherP absFilePath relFilePath <* endOfInput) (T.pack f) of | ||
Left e -> error e | ||
Right eAR -> case eAR of | ||
Left a -> pure a | ||
Right r -> do | ||
d <- getCurrentDirectory | ||
case parseOnly (absDirPath <* endOfInput) (T.pack (d ++ "/")) of | ||
Left e -> error e | ||
Right d' -> | ||
pure (d' </> r) | ||
i <- initINotify | ||
bracket (follow i f BS.putStr) (\watch -> removeWatch watch >> killINotify i) $ \_ -> forever $ threadDelay 50000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.