wip, report

This commit is contained in:
Dmitry Zuikov 2024-09-10 05:44:40 +03:00
parent 70c91a2a25
commit 7c7cdb4ed6
2 changed files with 39 additions and 8 deletions

View File

@ -330,13 +330,13 @@ runTop forms = do
entry $ bindMatch "report" $ nil_ $ lift . \case
( SymbolVal "template" : StringLike t : p ) -> do
runReport (Just t) p
report (Just t) p
( SymbolVal "--template" : StringLike t : p ) -> do
runReport (Just t) p
report (Just t) p
p -> do
runReport Nothing p
report Nothing p
entry $ bindMatch "fixme:key:show" $ nil_ \case
[ FixmeHashLike w ] -> lift $ void $ runMaybeT do

View File

@ -195,11 +195,42 @@ scanFiles = do
pure True
runReport :: (FixmePerks m, HasPredicate q) => Maybe FilePath -> q -> FixmeM m ()
runReport tpl q = do
debug $ "runReport" <+> pretty tpl
-- tpl <- asks fixmeEnvTemplates >>= readTVarIO
-- <&> HM.lookup (fromMaybe "default" tpl)
-- fixmies <- selectFixmeThin a
-- case tpl of
-- Nothing-> do
-- liftIO $ LBS.putStr $ Aeson.encodePretty fixmies
-- Just (Simple (SimpleTemplate simple)) -> do
-- for_ fixmies $ \(FixmeThin attr) -> do
-- let subst = [ (mkId k, mkStr @C v) | (k,v) <- HM.toList attr ]
-- let what = render (SimpleTemplate (inject subst simple))
-- & fromRight "render error"
-- liftIO $ hPutDoc stdout what
report :: (FixmePerks m, HasPredicate q) => Maybe FilePath -> q -> FixmeM m ()
report t q = do
tpl <- asks fixmeEnvTemplates >>= readTVarIO
<&> HM.lookup (maybe "default" fromString t)
fxs <- listFixme q
for_ fxs $ \fme -> do
liftIO $ print $ pretty fme
case tpl of
Nothing ->
liftIO $ LBS.putStr $ Aeson.encodePretty (fmap fixmeAttr fxs)
Just (Simple (SimpleTemplate simple)) -> do
for_ fxs $ \(Fixme{..}) -> do
let subst = [ (mkId k, mkStr @C v) | (k,v) <- HM.toList fixmeAttr ]
let what = render (SimpleTemplate (inject subst simple))
& fromRight "render error"
liftIO $ hPutDoc stdout what