{-# Language DeriveDataTypeable #-} {-# Language MultiWayIf #-} module Main (main) where import System.Console.CmdArgs.Implicit import System.Touched data Options = Options { call :: String , norecurse :: Bool , files :: [String] } deriving (Show, Data, Typeable) options :: Options options = Options { call = def &= help "The shell command to run on change" , norecurse = False &= help "Recurse into directories" , files = def &= args &= typ "FILES" } putErr :: String -> IO () putErr err = putStrLn $ "ERROR: " ++ err main :: IO () main = do opts <- cmdArgs options if | null $ files opts -> putErr "You must specify at least one file or directory." | null $ call opts -> putErr "You must specify a system command to run with the --call flag." | otherwise -> onChangeAny (not $ norecurse opts) (files opts) (cmd $ call opts)