@@ -6,22 +6,26 @@ import Network.Wai.Handler.Warp (run)
66import System.Environment (getArgs)
77import System.Console.CmdArgs
88import Text.Printf (printf)
9+import System.Directory (canonicalizePath)
10+import Control.Monad (unless)
911
1012data Args = Args
1113 { docroot :: FilePath
1214 , index :: [FilePath]
1315 , port :: Int
1416 , noindex :: Bool
17+ , quiet :: Bool
1518 }
1619 deriving (Show, Data, Typeable)
1720
18−defaultArgs = Args "." ["index.html", "index.htm"] 3000 False
21+defaultArgs = Args "." ["index.html", "index.htm"] 3000 False False
1922
2023main :: IO ()
2124main = do
2225 Args {..} <- cmdArgs defaultArgs
26+ docroot' <- canonicalizePath docroot
2327 args <- getArgs
24− printf "Serving directory %s on port %d with %s index files.\n" docroot port (if noindex then "no" else show index)
28+ unless quiet $ printf "Serving directory %s on port %d with %s index files.\n" docroot' port (if noindex then "no" else show index)
2529 run port $ staticApp StaticSettings
2630 { ssFolder = docroot
2731 , ssIndices = if noindex then [] else index