@@ -6,6 +6,7 @@ module Make
7 , reportType
7 , reportType
@@ -48,6 +49,7 @@ data Flags =
48 , _optimize :: Bool
49 , _optimize :: Bool
49 , _output :: Maybe Output
50 , _output :: Maybe Output
50 , _report :: Maybe ReportType
51 , _report :: Maybe ReportType
52+ , _docs :: Maybe FilePath
@@ -69,7 +71,7 @@ type Task a = Task.Task Exit.Make a
71run :: [FilePath] -> Flags -> IO ()
73run :: [FilePath] -> Flags -> IO ()
72−run paths (Flags debug optimize maybeOutput report) =
74+run paths (Flags debug optimize maybeOutput report _) =
73 do style <- getStyle report
75 do style <- getStyle report
74 Reporting.attemptWithStyle style Exit.makeToReport $ Task.run $
76 Reporting.attemptWithStyle style Exit.makeToReport $ Task.run $
75 do root <- getRoot
77 do root <- getRoot
@@ -450,25 +452,34 @@ output =
450 , _plural = "output files"
452 , _plural = "output files"
451 , _parser = parseOutput
453 , _parser = parseOutput
452 , _suggest = \_ -> return []
454 , _suggest = \_ -> return []
453− , _examples = exampleOutput
455+ , _examples = \_ -> return [ "elm.js", "index.html", "/dev/null" ]
457parseOutput :: String -> Maybe Output
459parseOutput :: String -> Maybe Output
458−parseOutput string =
460+parseOutput name
459− if string == "/dev/null" || string == "NUL" || string == "$null" then
460− Just DevNull
461+ | isDevNull name = Just DevNull
462+ | hasExt ".html" name = Just (Html name)
463+ | hasExt ".js" name = Just (JS name)
464+ | otherwise = Nothing
462− else if FP.takeExtension string == ".html" && length string > 5 then
465− else if FP.takeExtension string == ".js" && length string > 3 then
467+docsFile :: Parser FilePath
466− Just (JS string)
468+docsFile =
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"]
468− else
478+hasExt :: String -> String -> Bool
469− Nothing
479+hasExt ext path =
480+ FP.takeExtension path == ext && length path > length ext
472−exampleOutput :: String -> IO [String]
483+isDevNull :: String -> Bool
473−exampleOutput _ =
484+isDevNull name =
474− return [ "elm.js", "index.html", "/dev/null" ]
485+ name == "/dev/null" || name == "NUL" || name == "$null"