24 lines
864 B
Haskell
24 lines
864 B
Haskell
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
-- | Docster CLI - Convert Markdown with Mermaid diagrams to PDF/HTML
|
|
module Main (main) where
|
|
|
|
import Docster.Types (DocsterError(..))
|
|
import Docster.Compiler (compileToPDF, compileToHTML, compileToDOCX)
|
|
import System.Environment (getArgs)
|
|
import Control.Exception (throwIO)
|
|
|
|
-- | Parse command line arguments and return appropriate action
|
|
parseArgs :: [String] -> Either DocsterError (IO ())
|
|
parseArgs ["-pdf", path] = Right (compileToPDF path)
|
|
parseArgs ["-html", path] = Right (compileToHTML path)
|
|
parseArgs ["-docx", path] = Right (compileToDOCX path)
|
|
parseArgs _ = Left $ InvalidUsage "Usage: docster -pdf|-html|-docx <file.md>"
|
|
|
|
-- | Main entry point - parse arguments and execute appropriate action
|
|
main :: IO ()
|
|
main = do
|
|
args <- getArgs
|
|
case parseArgs args of
|
|
Left err -> throwIO err
|
|
Right action -> action |