From 9b5102c01c9e89a7819ec9d2919c5a62e24395d0 Mon Sep 17 00:00:00 2001 From: Jan Mas Rovira Date: Fri, 10 Jan 2025 10:12:42 +0100 Subject: [PATCH] restore single file --- app/Commands/Markdown.hs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/app/Commands/Markdown.hs b/app/Commands/Markdown.hs index a0b522c43a..ea4523e8ad 100644 --- a/app/Commands/Markdown.hs +++ b/app/Commands/Markdown.hs @@ -19,12 +19,39 @@ runCommand :: (Members AppEffects r) => MarkdownOptions -> Sem r () -runCommand opts = runPipelineOptions . runPipelineSetup $ do +runCommand opts = runReader opts $ do + case opts ^. markdownInputFile of + Nothing -> goProject + Just p -> + fromAppPathFileOrDir p >>= \case + Left f -> goSingleFile f + Right {} -> goProject + +goSingleFile :: + forall r. + (Members (Reader MarkdownOptions ': AppEffects) r) => + Path Abs File -> + Sem r () +goSingleFile f = do + let inputFile = + AppPath + { _pathPath = preFileFromAbs f, + _pathIsInput = True + } + scopedM :: Scoper.ScoperResult <- runPipelineNoOptions (Just inputFile) upToScopingEntry + goScoperResult scopedM + +goProject :: + forall r. + (Members (Reader MarkdownOptions ': AppEffects) r) => + Sem r () +goProject = runPipelineOptions . runPipelineSetup $ do res :: [ProcessedNode ScoperResult] <- processProjectUpToScoping - forM_ res (goScoperResult opts . (^. processedNodeData)) + forM_ res (goScoperResult . (^. processedNodeData)) -goScoperResult :: (Members AppEffects r) => MarkdownOptions -> Scoper.ScoperResult -> Sem r () -goScoperResult opts scopedM = do +goScoperResult :: (Members (Reader MarkdownOptions ': AppEffects) r) => Scoper.ScoperResult -> Sem r () +goScoperResult scopedM = do + opts <- ask let m :: Module 'Scoped 'ModuleTop = scopedM ^. Scoper.resultModule if | isNothing (m ^. moduleMarkdownInfo) ->