Commits

John Lenz committed 0746749

Read from standard input if no filename is given on the command line

Comments (0)

Files changed (2)

latex-candle.cabal

         latex-candle
       , base >= 4 && < 5
       , directory >= 1.1 && < 1.2
+      , text >= 0.11 && < 0.12
   else
     hs-source-dirs: . src
     build-depends:
 
 module Main where
 
-import Control.Monad (unless, when, forM_, (>=>))
+import Control.Monad (unless, forM_, (>=>))
 import Data.Version (showVersion)
+import qualified Data.Text.Lazy.IO as TLIO
 import System.Console.GetOpt
 import System.Environment (getProgName, getArgs)
 import System.Exit (exitWith, ExitCode(..), exitSuccess)
 
     opts <- foldl (>>=) (return defaultOptions) actions
 
-    when (null args) $ err 2 "No files specified"
-
     forM_ args $ \file -> do
         exists <- doesFileExist file
         unless exists $ err 3 $ file ++ ": No such file or directory"
 
-    forM_ args $
-        L.checkFile opts >=> mapM_ (putStr . show) 
+    if null args
+      then TLIO.getContents >>= return . L.check "stdin" opts >>= mapM_ (putStr . show)
+      else forM_ args $
+              L.checkFile opts >=> mapM_ (putStr . show) 
 
     return ()