From ec4f9b6dce743a281fe62bbac7a2c35125361383 Mon Sep 17 00:00:00 2001 From: Dmitry Zuikov Date: Fri, 30 Aug 2024 12:01:04 +0300 Subject: [PATCH] wip, fixme-new dump command --- fixme-new/lib/Fixme/Run.hs | 6 ++++++ fixme-new/lib/Fixme/Run/Internal.hs | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fixme-new/lib/Fixme/Run.hs b/fixme-new/lib/Fixme/Run.hs index 3e070ae4..eaa6454e 100644 --- a/fixme-new/lib/Fixme/Run.hs +++ b/fixme-new/lib/Fixme/Run.hs @@ -229,6 +229,12 @@ runTop forms = do _ -> throwIO $ BadFormException @C nil + entry $ bindMatch "dump" $ nil_ \case + [FixmeHashLike h] -> do + lift $ dumpFixme h + + _ -> throwIO $ BadFormException @C nil + entry $ bindMatch "cat" $ nil_ \case [SymbolVal "metadata", FixmeHashLike hash] -> do lift $ catFixmeMetadata hash diff --git a/fixme-new/lib/Fixme/Run/Internal.hs b/fixme-new/lib/Fixme/Run/Internal.hs index 06959be2..a333bdc7 100644 --- a/fixme-new/lib/Fixme/Run/Internal.hs +++ b/fixme-new/lib/Fixme/Run/Internal.hs @@ -249,6 +249,14 @@ catFixmeMetadata = cat_ True catFixme :: FixmePerks m => Text -> FixmeM m () catFixme = cat_ False +dumpFixme :: FixmePerks m => Text -> FixmeM m () +dumpFixme hash = do + flip runContT pure do + mha <- lift $ selectFixmeHash hash + ha <- ContT $ maybe1 mha (pure ()) + fme' <- lift $ selectFixme ha + liftIO $ print $ pretty fme' + cat_ :: FixmePerks m => Bool -> Text -> FixmeM m () cat_ metaOnly hash = do