on master help sign in
Parse the --report flag properly
7b6e55bEvan Czaplicki
ui/terminal/src/Main.hs+3−3
@@ -173,9 +173,9 @@ make =
173
173
174 makeFlags =
174 makeFlags =
175 flags Make.Flags
175 flags Make.Flags
176− |-- onOff "warn" "Report warnings to improve code quality."
176+ |-- onOff "debug" "Turn on debug mode. This allows you to (1) use functions like Debug.log and Debug.crash and (2) use the interactive debugger to rewind your programs."
177− |-- onOff "debug" "Generate programs in debug mode."
178− |-- flag "output" Output.output "Specify the name of the resulting JS file (use --output=/dev/null for no output)"
177+ |-- flag "output" Output.output "Specify the name of the resulting JS file. For example --output=assets/elm.js to generate the JS at assets/elm.js or --output=/dev/null to generate no output at all!"
178+ |-- 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!"
179 in
179 in
180 Interface "make" (Common summary) details example (zeroOrMore elmFile) makeFlags Make.run
180 Interface "make" (Common summary) details example (zeroOrMore elmFile) makeFlags Make.run
181
181
ui/terminal/src/Make.hs+22−5
@@ -1,7 +1,8 @@
1module Make
1module Make
2 ( Flags(..)
2 ( Flags(..)
3− , ReportType(..)
4 , run
3 , run
4+ , ReportType(..)
5+ , reportType
5 )
6 )
6 where
7 where
7
8
@@ -14,6 +15,7 @@ import qualified Generate.Output as Output
14import qualified Reporting.Task as Task
15import qualified Reporting.Task as Task
15import qualified Reporting.Progress.Json as Json
16import qualified Reporting.Progress.Json as Json
16import qualified Reporting.Progress.Terminal as Terminal
17import qualified Reporting.Progress.Terminal as Terminal
18+import Terminal.Args (Parser(..))
17
19
18
20
19
21
@@ -28,10 +30,6 @@ data Flags =
28 }
30 }
29
31
30
32
31−data ReportType
32− = Json
33−
34−
35run :: [FilePath] -> Flags -> IO ()
33run :: [FilePath] -> Flags -> IO ()
36run paths (Flags debug output report) =
34run paths (Flags debug output report) =
37 let
35 let
@@ -53,3 +51,22 @@ run paths (Flags debug output report) =
53 void $ Task.run reporter $
51 void $ Task.run reporter $
54 do summary <- Project.getRoot
52 do summary <- Project.getRoot
55 Project.compile outputOptions summary paths
53 Project.compile outputOptions summary paths
54+
55+
56+
57+-- REPORT
58+
59+
60+data ReportType
61+ = Json
62+
63+
64+reportType :: Parser ReportType
65+reportType =
66+ Parser
67+ { _singular = "report type"
68+ , _plural = "report types"
69+ , _parser = \string -> if string == "json" then Just Json else Nothing
70+ , _suggest = \_ -> return ["json"]
71+ , _examples = \_ -> return ["json"]
72+ }