1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 18:13:56 +03:00
juvix/app/Commands/Html.hs
Jonathan Cubides 3b3ea45da9
Rename MiniJuvix to Juvix (#259)
* Renaming MiniJuvix to Juvix

* Make Ormolu happy

* Make Hlint happy

* Remove redundant imports

* Fix shell tests and add target ci to our Makefile

* Make pre-commit happy
2022-07-08 13:59:45 +02:00

54 lines
1.2 KiB
Haskell

module Commands.Html where
import Juvix.Prelude hiding (Doc)
import Juvix.Syntax.Concrete.Scoped.Pretty.Html
import Options.Applicative
data HtmlOptions = HtmlOptions
{ _htmlRecursive :: Bool,
_htmlTheme :: Theme,
_htmlOutputDir :: FilePath,
_htmlPrintMetadata :: Bool
}
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)"
)
_htmlOutputDir <-
option
str
( long "output-dir"
<> metavar "DIR"
<> value "html"
<> showDefault
<> help "html output directory"
<> action "directory"
)
_htmlPrintMetadata <-
switch
( long "print-metadata"
<> help "Add HTML footer with metadata"
)
pure HtmlOptions {..}
where
parseTheme :: String -> Either String Theme
parseTheme s = case s of
"nord" -> Right Nord
"ayu" -> Right Ayu
_ -> Left $ "unrecognised theme: " <> s