diff --git a/hbs2-git/git-hbs2/RunShow.hs b/hbs2-git/git-hbs2/RunShow.hs index 3b3e3b34..84df6d75 100644 --- a/hbs2-git/git-hbs2/RunShow.hs +++ b/hbs2-git/git-hbs2/RunShow.hs @@ -5,10 +5,11 @@ import HBS2.Base58 import HBS2Git.App import HBS2Git.State -import HBS2Git.Config +import HBS2Git.Config import HBS2Git.ListRefs import Data.Foldable +import Prettyprinter.Render.Terminal data ShowObject = ShowRef RepoRef | ShowConfig @@ -22,24 +23,24 @@ showRef h = do print $ "current state for" <+> pretty (AsBase58 h) print $ "head:" <+> pretty hd print $ pretty "last operations:" - for_ imported (\(t,h1,h2) -> print $ pretty t <+> pretty h1 <+> pretty h2) + for_ imported (\(t,h1,h2) -> print $ pretty t <+> pretty h1 <+> pretty h2) showRefs :: MonadIO m => App m () showRefs = do - liftIO $ print $ pretty "References:" + liftIO $ putDoc $ line <> green "References:" <> section runListRefs showConfig :: MonadIO m => App m () showConfig = liftIO do ConfigPathInfo{..} <- getConfigPathInfo cfg <- readFile configFilePath - print $ "Config file location:" <> line <> pretty configFilePath <> line - print $ "Config contents:" <> line <> pretty cfg + putDoc $ green "Config file location:" <> section <> pretty configFilePath <> section + putDoc $ green "Config contents:" <> line <> pretty cfg showSummary :: MonadIO m => App m () showSummary = do showRefs - liftIO $ print $ pretty "" + liftIO $ putDoc section showConfig runShow :: MonadIO m => Maybe ShowObject -> App m () diff --git a/hbs2-git/lib/HBS2Git/App.hs b/hbs2-git/lib/HBS2Git/App.hs index b4109013..d674d149 100644 --- a/hbs2-git/lib/HBS2Git/App.hs +++ b/hbs2-git/lib/HBS2Git/App.hs @@ -52,7 +52,7 @@ import System.IO.Unsafe (unsafePerformIO) import Data.Cache qualified as Cache import Control.Concurrent.Async import System.Environment -import Control.Monad.Catch +import Prettyprinter.Render.Terminal instance MonadIO m => HasCfgKey ConfBranch (Set String) m where key = "branch" @@ -464,3 +464,9 @@ loadCredentials fp = do pure () +green = annotate (color Green) + +yellow = annotate (color Yellow) + +section = line <> line + diff --git a/hbs2-git/lib/HBS2Git/Export.hs b/hbs2-git/lib/HBS2Git/Export.hs index bd96922d..e2fe7ee6 100644 --- a/hbs2-git/lib/HBS2Git/Export.hs +++ b/hbs2-git/lib/HBS2Git/Export.hs @@ -208,9 +208,6 @@ runExport :: forall m . (MonadIO m, MonadCatch m, HasProgress (App m)) => Maybe FilePath -> RepoRef -> App m () runExport fp h = do - let green = annotate (color Green) - let yellow = annotate (color Yellow) - let section = line <> line liftIO $ putDoc $ line diff --git a/hbs2-git/lib/HBS2Git/ListRefs.hs b/hbs2-git/lib/HBS2Git/ListRefs.hs index 717b050c..9ac1c41c 100644 --- a/hbs2-git/lib/HBS2Git/ListRefs.hs +++ b/hbs2-git/lib/HBS2Git/ListRefs.hs @@ -10,6 +10,7 @@ import HBS2.Git.Local.CLI import Data.Functor import Data.Text qualified as Text import Data.Traversable +import Prettyprinter.Render.Terminal data AsRemoteEntry = AsRemoteEntry { remoteName :: Text, @@ -56,11 +57,11 @@ runListRefs = do } ) let header = - fill remoteNameColWidth "Name" - <+> fill remoteURLColWidth "URL" - <+> fill remoteRefValueColWidth "Reference value" - liftIO $ print header - liftIO $ print $ vcat $ pretty <$> remoteEntries + fill remoteNameColWidth (green "Name") + <+> fill remoteURLColWidth (green "URL") + <+> fill remoteRefValueColWidth (green "Reference value") + liftIO $ putDoc $ header <> line + liftIO $ putDoc $ vcat $ pretty <$> remoteEntries where isHbs2 (_, b) = Text.isPrefixOf hbs2Prefix b