Skip to content

Commit

Permalink
restore single file
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira committed Jan 10, 2025
1 parent 1eb1ab0 commit 9b5102c
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions app/Commands/Markdown.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down

0 comments on commit 9b5102c

Please sign in to comment.