4import Control.Monad (foldM)
5import qualified Data.Maybe as Maybe
6import Text.Blaze.Html.Renderer.String (renderHtml)
7import qualified Data.ByteString.Lazy.Char8 as BS
8import qualified System.Console.CmdArgs as CmdArgs
13import Build.Dependencies (getSortedDependencies)
14import qualified Generate.Html as Html
15import qualified Metadata.Prelude as Prelude
16import qualified Build.Utils as Utils
17import qualified Build.Flags as Flag
18import qualified Build.File as File
19import qualified Elm.Internal.Paths as Path
22main = do setNumCapabilities =<< getNumProcessors
23 compileArgs =<< CmdArgs.cmdArgs Flag.flags
25compileArgs :: Flag.Flags -> IO ()
27 case Flag.files flags of
28 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
29 fs -> mapM_ (build flags) fs
31build :: Flag.Flags -> FilePath -> IO ()
33 do let noPrelude = Flag.no_prelude flags
34 builtIns <- Prelude.interfaces noPrelude
36 files <- if Flag.make flags
37 then getSortedDependencies (Flag.src_dir flags) builtIns rootFile
38 else return [rootFile]
41 File.build flags (length files) builtIns "" files
43 js <- foldM appendToOutput BS.empty files
47 then do putStr "Generating JavaScript ... "
49 else do putStr "Generating HTML ... "
50 return (makeHtml js moduleName)
52 let targetFile = Utils.buildPath flags rootFile extension
53 createDirectoryIfMissing True (takeDirectory targetFile)
54 BS.writeFile targetFile code
58 appendToOutput :: BS.ByteString -> FilePath -> IO BS.ByteString
59 appendToOutput js filePath = do
60 src <- BS.readFile (Utils.elmo flags filePath)
61 return (BS.append src js)
63 sources js = map Html.Link (Flag.scripts flags) ++ [ Html.Source js ]
65 makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
67 rtsPath = Maybe.fromMaybe Path.runtime (Flag.runtime flags)
68 html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""
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