@@ -1,19 +1,60 @@
1{-# LANGUAGE DeriveDataTypeable #-}
1{-# LANGUAGE DeriveDataTypeable #-}
2+{-# LANGUAGE OverloadedStrings #-}
2import Network.Wai.Handler.DevelServer (runQuit)
3import Network.Wai.Handler.DevelServer (runQuit)
3import System.Console.CmdArgs
4import System.Console.CmdArgs
5+import qualified Data.Attoparsec.Text.Lazy as A
6+import qualified Data.Text.Lazy.IO as TIO
7+import Control.Applicative ((<|>))
8+import Data.Char (isSpace)
9+import Data.Maybe (mapMaybe)
5data Devel = Devel
11data Devel = Devel
6 { port :: Int
12 { port :: Int
7 , moduleName :: String
13 , moduleName :: String
8 , function :: String
14 , function :: String
10 deriving (Show, Data, Typeable)
17 deriving (Show, Data, Typeable)
12main :: IO ()
19main :: IO ()
14− Devel p m f <- cmdArgs Devel
21+ Devel p m f y <- cmdArgs Devel
15 { port = 3000 &= argPos 0 &= typ "PORT"
22 { port = 3000 &= argPos 0 &= typ "PORT"
16 , moduleName = "" &= argPos 1 &= typ "MODULE"
23 , moduleName = "" &= argPos 1 &= typ "MODULE"
17 , function = "" &= argPos 2 &= typ "FUNCTION"
24 , function = "" &= argPos 2 &= typ "FUNCTION"
18 } &= summary "WAI development web server"
26 } &= summary "WAI development web server"
19− runQuit p m f $ const $ return []
27+ runQuit p m f $ if y then determineHamletDeps else (const $ return [])
29+data TempType = Hamlet | Cassius | Lucius | Julius | Widget
32+determineHamletDeps :: FilePath -> IO [FilePath]
33+determineHamletDeps x = do
35+ let z = A.parse (A.many $ (parser <|> (A.anyChar >> return Nothing))) y
37+ A.Fail{} -> return []
38+ A.Done _ r -> return $ mapMaybe go r
40+ go (Just (Hamlet, f)) = Just $ "hamlet/" ++ f ++ ".hamlet"
41+ go (Just (Widget, f)) = Just $ "hamlet/" ++ f ++ ".hamlet"
44+ ty <- (A.string "$(hamletFile " >> return Hamlet)
45+ <|> (A.string "$(cassiusFile " >> return Cassius)
46+ <|> (A.string "$(luciusFile " >> return Lucius)
47+ <|> (A.string "$(juliusFile " >> return Julius)
48+ <|> (A.string "$(widgetFile " >> return Widget)
49+ <|> (A.string "$(Settings.hamletFile " >> return Hamlet)
50+ <|> (A.string "$(Settings.cassiusFile " >> return Cassius)
51+ <|> (A.string "$(Settings.luciusFile " >> return Lucius)
52+ <|> (A.string "$(Settings.juliusFile " >> return Julius)
53+ <|> (A.string "$(Settings.widgetFile " >> return Widget)
56+ y <- A.many1 $ A.satisfy (/= '"')
60+ return $ Just (ty, y)