4import Control.Monad (msum,guard)
5import Control.Monad.Trans (MonadIO(liftIO))
6import Data.List (isPrefixOf, isSuffixOf)
8import Happstack.Server.Compression
9import System.Environment
12serve :: String -> IO ()
14 putStrLn "Elm Server 0.1.0: running at <http://localhost:8000>"
15 simpleHTTP nullConf $ do
16 compressedResponseFilter
17 msum [ uriRest (serveElm libLoc)
18 , serveDirectory EnableBrowsing [] "."
21serveElm libLoc fp = do
23 guard (".elm" `isSuffixOf` path)
24 content <- liftIO (readFile path)
25 ok . toResponse $ compileToHtml libLoc path content
28main = getArgs >>= parse
30parse ("--help":_) = putStrLn usage
31parse ("--version":_) = putStrLn "The Elm Server 0.1.0"
32parse [] = serve "/elm-mini.js"
34 | "--runtime-location=" `isPrefixOf` arg =
35 serve . tail $ dropWhile (/='=') arg
36 | otherwise = putStrLn usageMini
37parse _ = putStrLn usageMini
40 "Usage: elm-server [OPTIONS]\n\
41 \Try `elm-server --help' for more information."
44 "Usage: elm-server [OPTIONS]\n\
45 \Compiles and serves .elm files from the current directory.\n\
46 \Example: elm-server\n\
48 \Resource Locations:\n\
49 \ --runtime-location set the location of the Elm runtime (elm-mini.js)\n\
51 \Compiler Information:\n\
52 \ --version print the version information and exit\n\
53 \ --help display this help and exit\n\
55 \Elm home page: <http://elm-lang.org>"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list