diff --git a/terminal/src/Main.hs b/terminal/src/Main.hs index 1c88e1b65..eadc54264 100644 --- a/terminal/src/Main.hs +++ b/terminal/src/Main.hs @@ -138,7 +138,7 @@ make = flags Make.Flags |-- onOff "debug" "Turn on the time-travelling debugger. It allows you to rewind and replay events. The events can be imported/exported into a file, which makes for very precise bug reports!" |-- onOff "optimize" "Turn on optimizations to make code smaller and faster. For example, the compiler renames record fields to be as short as possible and unboxes values to reduce allocation." - |-- flag "output" Make.output "Specify the name of the resulting JS file. For example --output=assets/gren.js to generate the JS at assets/gren.js or --output=/dev/null to generate no output at all!" + |-- flag "output" Make.output "Specify the name of the resulting JS file. For example --output=assets/gren.js to generate the JS at assets/gren.js. You can also use --output=/dev/stdout to output the JS to the terminal, or --output=/dev/null to generate no output at all!" |-- flag "report" Make.reportType "You can say --report=json to get error messages as JSON. This is only really useful if you are an editor plugin. Humans should avoid it!" |-- flag "docs" Make.docsFile "Generate a JSON file of documentation for a package. Eventually it will be possible to preview docs with `reactor` because it is quite hard to deal with these JSON files directly." in Terminal.Command "make" Uncommon details example (zeroOrMore grenFile) makeFlags Make.run diff --git a/terminal/src/Make.hs b/terminal/src/Make.hs index ab20fd00c..64d897cfd 100644 --- a/terminal/src/Make.hs +++ b/terminal/src/Make.hs @@ -28,6 +28,7 @@ import qualified Reporting.Exit as Exit import qualified Reporting.Task as Task import qualified System.Directory as Dir import qualified System.FilePath as FP +import qualified System.IO as IO import Terminal (Parser (..)) -- FLAGS @@ -44,6 +45,7 @@ data Output = JS FilePath | Html FilePath | DevNull + | DevStdOut data ReportType = Json @@ -91,6 +93,14 @@ runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) = do builder <- toBuilder root details desiredMode artifacts generate style "gren.js" builder (NE.List name names) + Just DevStdOut -> + case getMains artifacts of + [] -> + return () + _ -> + do + builder <- toBuilder root details desiredMode artifacts + Task.io $ B.hPutBuilder IO.stdout builder Just DevNull -> return () Just (JS target) -> @@ -239,11 +249,12 @@ output = _plural = "output files", _parser = parseOutput, _suggest = \_ -> return [], - _examples = \_ -> return ["gren.js", "index.html", "/dev/null"] + _examples = \_ -> return ["gren.js", "index.html", "/dev/null", "/dev/stdout"] } parseOutput :: String -> Maybe Output parseOutput name + | name == "/dev/stdout" = Just DevStdOut | isDevNull name = Just DevNull | hasExt ".html" name = Just (Html name) | hasExt ".js" name = Just (JS name)