on master help sign in
add back Make.docsFile to parse --docs flag
effb8beEvan Czaplicki
terminal/src/Make.hs+25−14
@@ -6,6 +6,7 @@ module Make
6 , run
6 , run
7 , reportType
7 , reportType
8 , output
8 , output
9+ , docsFile
9 )
10 )
10 where
11 where
11
12
@@ -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
51 }
53 }
52
54
53
55
@@ -69,7 +71,7 @@ type Task a = Task.Task Exit.Make a
69
71
70
72
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" ]
454 }
456 }
455
457
456
458
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
461
465
462− else if FP.takeExtension string == ".html" && length string > 5 then
463− Just (Html string)
464
466
465− else if FP.takeExtension string == ".js" && length string > 3 then
467+docsFile :: Parser FilePath
466− Just (JS string)
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+
467
477
468− else
478+hasExt :: String -> String -> Bool
469− Nothing
479+hasExt ext path =
480+ FP.takeExtension path == ext && length path > length ext
470
481
471
482
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"