@@ -62,49 +62,57 @@ type Task a = Task.Task Exit.Make a
6262
6363
6464run :: [FilePath] -> Flags -> IO ()
65−run paths (Flags debug optimize maybeOutput report maybeDocs) =
65+run paths flags@(Flags _ _ _ report _) =
6666 do style <- getStyle report
67− Reporting.attemptWithStyle style Exit.makeToReport $ Task.run $
68− do root <- Task.mio Exit.MakeNoOutline Stuff.findRoot
69− desiredMode <- getMode debug optimize
70− details <- Task.eio Exit.MakeBadDetails (Details.load style root)
71− case paths of
72− [] ->
73− do exposed <- getExposed details
74− buildExposed style root details maybeDocs exposed
75−
76− p:ps ->
77− do artifacts <- buildPaths style root details (NE.List p ps)
78− case maybeOutput of
79− Nothing ->
80− case getMains artifacts of
81− [] ->
82− return ()
83−
84− [name] ->
85− do builder <- toBuilder root details desiredMode artifacts
86− generate style "index.html" (Html.sandwich name builder) (NE.List name [])
87−
88− name:names ->
89− do builder <- toBuilder root details desiredMode artifacts
90− generate style "elm.js" builder (NE.List name names)
91−
92− Just DevNull ->
93− return ()
94−
95− Just (JS target) ->
96− case getNoMains artifacts of
97− [] ->
98− do builder <- toBuilder root details desiredMode artifacts
99− generate style target builder (Build.getMainNames artifacts)
100−
101− name:names ->
102− Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
103−
104− Just (Html target) ->
105− do name <- hasOneMain artifacts
106− builder <- toBuilder root details desiredMode artifacts
107− generate style target (Html.sandwich name builder) (NE.List name [])
67+ maybeRoot <- Stuff.findRoot
68+ Reporting.attemptWithStyle style Exit.makeToReport $
69+ case maybeRoot of
70+ Just root -> runHelp root paths style flags
71+ Nothing -> return $ Left $ Exit.MakeNoOutline
72+
73+
74+runHelp :: FilePath -> [FilePath] -> Reporting.Style -> Flags -> IO (Either Exit.Make ())
75+runHelp root paths style (Flags debug optimize maybeOutput _ maybeDocs) =
76+ Stuff.withRootLock root $ Task.run $
77+ do desiredMode <- getMode debug optimize
78+ details <- Task.eio Exit.MakeBadDetails (Details.load style root)
79+ case paths of
80+ [] ->
81+ do exposed <- getExposed details
82+ buildExposed style root details maybeDocs exposed
83+
84+ p:ps ->
85+ do artifacts <- buildPaths style root details (NE.List p ps)
86+ case maybeOutput of
87+ Nothing ->
88+ case getMains artifacts of
89+ [] ->
90+ return ()
91+
92+ [name] ->
93+ do builder <- toBuilder root details desiredMode artifacts
94+ generate style "index.html" (Html.sandwich name builder) (NE.List name [])
95+
96+ name:names ->
97+ do builder <- toBuilder root details desiredMode artifacts
98+ generate style "elm.js" builder (NE.List name names)
99+
100+ Just DevNull ->
101+ return ()
102+
103+ Just (JS target) ->
104+ case getNoMains artifacts of
105+ [] ->
106+ do builder <- toBuilder root details desiredMode artifacts
107+ generate style target builder (Build.getMainNames artifacts)
108+
109+ name:names ->
110+ Task.throw (Exit.MakeNonMainFilesIntoJavaScript name names)
111+
112+ Just (Html target) ->
113+ do name <- hasOneMain artifacts
114+ builder <- toBuilder root details desiredMode artifacts
115+ generate style target (Html.sandwich name builder) (NE.List name [])
108116
109117
110118