2022-05-06 12:48:07 +03:00
|
|
|
module Commands.Html where
|
|
|
|
|
2022-08-03 14:20:40 +03:00
|
|
|
import Juvix.Compiler.Backend.Html.Data.Theme
|
2022-07-08 14:59:45 +03:00
|
|
|
import Juvix.Prelude hiding (Doc)
|
2022-05-06 12:48:07 +03:00
|
|
|
import Options.Applicative
|
|
|
|
|
|
|
|
data HtmlOptions = HtmlOptions
|
2022-06-09 17:36:07 +03:00
|
|
|
{ _htmlRecursive :: Bool,
|
2022-06-20 19:12:45 +03:00
|
|
|
_htmlTheme :: Theme,
|
2022-06-21 18:03:22 +03:00
|
|
|
_htmlOutputDir :: FilePath,
|
|
|
|
_htmlPrintMetadata :: Bool
|
2022-05-06 12:48:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
makeLenses ''HtmlOptions
|
|
|
|
|
|
|
|
parseHtml :: Parser HtmlOptions
|
|
|
|
parseHtml = do
|
|
|
|
_htmlRecursive <-
|
|
|
|
switch
|
|
|
|
( long "recursive"
|
|
|
|
<> help "export imported modules recursively"
|
|
|
|
)
|
|
|
|
_htmlTheme <-
|
|
|
|
option
|
|
|
|
(eitherReader parseTheme)
|
|
|
|
( long "theme"
|
|
|
|
<> metavar "THEME"
|
|
|
|
<> value Ayu
|
|
|
|
<> showDefault
|
|
|
|
<> help "selects a theme: ayu (light); nord (dark)"
|
|
|
|
)
|
2022-06-20 19:12:45 +03:00
|
|
|
_htmlOutputDir <-
|
|
|
|
option
|
|
|
|
str
|
|
|
|
( long "output-dir"
|
|
|
|
<> metavar "DIR"
|
|
|
|
<> value "html"
|
|
|
|
<> showDefault
|
|
|
|
<> help "html output directory"
|
|
|
|
<> action "directory"
|
|
|
|
)
|
2022-06-21 18:03:22 +03:00
|
|
|
_htmlPrintMetadata <-
|
|
|
|
switch
|
|
|
|
( long "print-metadata"
|
|
|
|
<> help "Add HTML footer with metadata"
|
|
|
|
)
|
2022-05-06 12:48:07 +03:00
|
|
|
pure HtmlOptions {..}
|
|
|
|
where
|
|
|
|
parseTheme :: String -> Either String Theme
|
|
|
|
parseTheme s = case s of
|
|
|
|
"nord" -> Right Nord
|
|
|
|
"ayu" -> Right Ayu
|
|
|
|
_ -> Left $ "unrecognised theme: " <> s
|