on master help sign in
Merge branch 'pr/613' into webgl
commit1062ff116b7eaa8e9cf03e3d908bf6fa587333de authorEvan Czaplicki <info@elm-lang.org> dateSun 11 May 2014, 12:06 (12 years ago) parent31ca14d9d678a1
2 files changed+14−7
compiler/Build/Flags.hs+7−4 compiler/Compiler.hs+7−3
compiler/Build/Flags.hs+7−4
@@ -7,7 +7,8 @@ import System.Console.CmdArgs
77data Flags = Flags
88 { make :: Bool
99 , files :: [FilePath]
10− , runtime :: Maybe FilePath
10+ , set_runtime :: Maybe FilePath
11+ , get_runtime :: Bool
1112 , only_js :: Bool
1213 , print_types :: Bool
1314 , scripts :: [FilePath]
@@ -28,8 +29,10 @@ flags = Flags
2829 &= help "Do not import Prelude by default, used only when compiling standard libraries."
2930 , scripts = [] &= typFile
3031 &= help "Load JavaScript files in generated HTML. Files will be included in the given order."
31− , runtime = Nothing &= typFile
32− &= help "Specify a custom location for Elm's runtime system."
32+ , set_runtime = Nothing &= typFile
33+ &= help "Specify a custom location for Elm's runtime system."
34+ , get_runtime = False
35+ &= help "Print the absolute path to the default Elm runtime."
3336 , cache_dir = "cache" &= typFile
3437 &= help "Directory for files cached to make builds faster. Defaults to cache/ directory."
3538 , build_dir = "build" &= typFile
@@ -37,7 +40,7 @@ flags = Flags
3740 , src_dir = ["."] &= typFile
3841 &= help "Additional source directories besides project root. Searched when using --make"
3942 , print_types = False
40− &= help "Print out infered types of top-level definitions."
43+ &= help "Print out inferred types of top-level definitions."
4144 } &= help "Compile Elm programs to HTML, CSS, and JavaScript."
4245 &= helpArg [explicit, name "help", name "h"]
4346 &= versionArg [explicit, name "version", name "v", summary (show Version.elmVersion)]
compiler/Compiler.hs+7−3
@@ -1,12 +1,13 @@
11{-# OPTIONS_GHC -W #-}
22module Main where
33
4−import Control.Monad (foldM)
4+import Control.Monad (foldM, when)
55import qualified Data.Maybe as Maybe
66import Text.Blaze.Html.Renderer.String (renderHtml)
77import qualified Data.ByteString.Lazy.Char8 as BS
88import qualified System.Console.CmdArgs as CmdArgs
99import System.Directory
10+import System.Exit (exitSuccess)
1011import System.FilePath
1112import GHC.Conc
1213
@@ -24,7 +25,10 @@ main = do setNumCapabilities =<< getNumProcessors
2425
2526compileArgs :: Flag.Flags -> IO ()
2627compileArgs flags =
27− case Flag.files flags of
28+ do when (Flag.get_runtime flags) $
29+ do putStrLn Path.runtime
30+ exitSuccess
31+ case Flag.files flags of
2832 [] -> putStrLn "Usage: elm [OPTIONS] [FILES]\nFor more help: elm --help"
2933 fs -> mapM_ (build flags) fs
3034
@@ -65,5 +69,5 @@ build flags rootFile =
6569
6670 makeHtml js moduleName = ("html", BS.pack $ renderHtml html)
6771 where
68− rtsPath = Maybe.fromMaybe Path.runtime (Flag.runtime flags)
72+ rtsPath = Maybe.fromMaybe Path.runtime (Flag.set_runtime flags)
6973 html = Html.generate rtsPath (takeBaseName rootFile) (sources js) moduleName ""