@@ -6,6 +6,7 @@ module Make
66 , run
77 , reportType
88 , output
9+ , docsFile
910 )
1011 where
1112
@@ -48,6 +49,7 @@ data Flags =
4849 , _optimize :: Bool
4950 , _output :: Maybe Output
5051 , _report :: Maybe ReportType
52+ , _docs :: Maybe FilePath
5153 }
5254
5355
@@ -69,7 +71,7 @@ type Task a = Task.Task Exit.Make a
6971
7072
7173run :: [FilePath] -> Flags -> IO ()
72−run paths (Flags debug optimize maybeOutput report) =
74+run paths (Flags debug optimize maybeOutput report _) =
7375 do style <- getStyle report
7476 Reporting.attemptWithStyle style Exit.makeToReport $ Task.run $
7577 do root <- getRoot
@@ -450,25 +452,34 @@ output =
450452 , _plural = "output files"
451453 , _parser = parseOutput
452454 , _suggest = \_ -> return []
453− , _examples = exampleOutput
455+ , _examples = \_ -> return [ "elm.js", "index.html", "/dev/null" ]
454456 }
455457
456458
457459parseOutput :: String -> Maybe Output
458−parseOutput string =
459− if string == "/dev/null" || string == "NUL" || string == "$null" then
460− Just DevNull
460+parseOutput name
461+ | isDevNull name = Just DevNull
462+ | hasExt ".html" name = Just (Html name)
463+ | hasExt ".js" name = Just (JS name)
464+ | otherwise = Nothing
461465
462− else if FP.takeExtension string == ".html" && length string > 5 then
463− Just (Html string)
464466
465− else if FP.takeExtension string == ".js" && length string > 3 then
466− Just (JS string)
467+docsFile :: Parser FilePath
468+docsFile =
469+ Parser
470+ { _singular = "json file"
471+ , _plural = "json files"
472+ , _parser = \name -> if hasExt ".json" name then Just name else Nothing
473+ , _suggest = \_ -> return []
474+ , _examples = \_ -> return ["docs.json","documentation.json"]
475+ }
476+
467477
468− else
469− Nothing
478+hasExt :: String -> String -> Bool
479+hasExt ext path =
480+ FP.takeExtension path == ext && length path > length ext
470481
471482
472−exampleOutput :: String -> IO [String]
473−exampleOutput _ =
474− return [ "elm.js", "index.html", "/dev/null" ]
483+isDevNull :: String -> Bool
484+isDevNull name =
485+ name == "/dev/null" || name == "NUL" || name == "$null"