From 85f147feb47697d677669c4721c2efac7f86cd6d Mon Sep 17 00:00:00 2001 From: Greg Pfeil Date: Tue, 20 Aug 2024 11:28:16 -0600 Subject: [PATCH 1/2] Improve transcript runner output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, it would output messages like ⚙️ Processing stanza Just 6 of 7. and ⚙️ Processing stanza Nothing of 7. which was especially confusing when there was text or some other non-Unison block at the end of the transcript. Now the messages look like ⏩ Skipping non-executable Markdown block. ⚙️ Processing stanza 6 of 7. ✔️ Completed transcript. The one shortcoming is that I don’t know how to clear the line after the carriage return, so I added whitespace padding to make sure the previous messages get overwritten. --- .../src/Unison/Codebase/Transcript/Runner.hs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs index 6e084a2eb..5f3d5b35f 100644 --- a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs +++ b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs @@ -300,16 +300,21 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime config ucmV _ <- liftIO (writeIORef mStanza maybeStanza) case maybeStanza of Nothing -> do - liftIO (putStrLn "") + liftIO (putStrLn "\r✔️ Completed transcript. ") pure $ Right QuitI - Just (s, idx) -> do + Just (s, midx) -> do unless (Verbosity.isSilent verbosity) . liftIO $ do putStr $ - "\r⚙️ Processing stanza " - ++ show idx - ++ " of " - ++ show (length stanzas) - ++ "." + maybe + "\r⏩ Skipping non-executable Markdown block." + ( \idx -> + "\r⚙️ Processing stanza " + ++ show idx + ++ " of " + ++ show (length stanzas) + ++ ". " + ) + midx IO.hFlush IO.stdout either ( \node -> do From 8137f5797a2173417724bc21364edd34be195e65 Mon Sep 17 00:00:00 2001 From: Arya Irani Date: Tue, 3 Sep 2024 13:10:32 -0400 Subject: [PATCH 2/2] switch whitespace spans for `clearCurrentLine` --- unison-cli/src/Unison/Codebase/Transcript/Runner.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs index 5f3d5b35f..5b636bfcd 100644 --- a/unison-cli/src/Unison/Codebase/Transcript/Runner.hs +++ b/unison-cli/src/Unison/Codebase/Transcript/Runner.hs @@ -299,11 +299,13 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime config ucmV maybeStanza <- atomically (Q.tryDequeue inputQueue) _ <- liftIO (writeIORef mStanza maybeStanza) case maybeStanza of - Nothing -> do - liftIO (putStrLn "\r✔️ Completed transcript. ") + Nothing -> liftIO do + clearCurrentLine + putStrLn "\r✔️ Completed transcript." pure $ Right QuitI Just (s, midx) -> do unless (Verbosity.isSilent verbosity) . liftIO $ do + clearCurrentLine putStr $ maybe "\r⏩ Skipping non-executable Markdown block." @@ -312,7 +314,7 @@ run isTest verbosity dir stanzas codebase runtime sbRuntime nRuntime config ucmV ++ show idx ++ " of " ++ show (length stanzas) - ++ ". " + ++ "." ) midx IO.hFlush IO.stdout