Verified Commit 2c85b1f5 authored by Camil Staps's avatar Camil Staps 🚀

Add output directory option

parent d4d301ba
......@@ -16,24 +16,50 @@ import Text.HTML
import Clean.Doc.ModuleCollection
import Clean.Doc.ModuleCollection.HTML
:: Options =
{ output_directory :: !FilePath
, module_finding_options :: !ModuleFindingOptions
}
defaultOptions :: !*World -> *(!Options, !*World)
defaultOptions w
# (mfo,w) = defaultModuleFindingOptions w
# opts =
{ output_directory = "doc"
, module_finding_options = mfo
}
= (opts,w)
optionDescription :: Option Options
optionDescription = WithHelp True $ Options
[ Shorthand "-o" "--output-directory" $ Option
"--output-directory"
(\dir opts -> Ok {opts & output_directory=dir})
"DIR"
"The output directory"
, Biject
(\opts -> opts.module_finding_options)
(\opts mfo -> {opts & module_finding_options=mfo})
moduleFindingOptionDescription
]
Start w
# ([prog:args],w) = getCommandLine w
# (opts,w) = defaultModuleFindingOptions w
# opts & include_libraries = []
# opts = parseOptions (WithHelp True moduleFindingOptionDescription) args opts
# (opts,w) = defaultOptions w
# opts = parseOptions optionDescription args opts
| isError opts = exit (fromError opts) w
# opts = fromOk opts
# (errs,fps,w) = findAllModules opts w
# (errs,fps,w) = findAllModules opts.module_finding_options w
| errs=:[_:_] = exit (map snd errs) w
# (modcoll,w) = mapSt (collectModule opts) fps w
# (modcoll,w) = mapSt (collectModule opts.module_finding_options) fps w
| any isError modcoll = exit [e \\ Error e <- modcoll] w
# modcoll = map fromOk modcoll
| isEmpty modcoll = exit ["No modules found"] w
# html = generateHTML modcoll
# (errs,w) = writeHTMLSite "doc" html w
# (errs,w) = writeHTMLSite opts.output_directory html w
| errs=:[_:_] = exit errs w
= w
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment