little bit formatting

This commit is contained in:
Dmitry Zuikov 2023-04-05 16:51:24 +03:00
parent 6f5bd94221
commit 261641f719
4 changed files with 20 additions and 15 deletions

View File

@ -9,6 +9,7 @@ import HBS2Git.Config
import HBS2Git.ListRefs import HBS2Git.ListRefs
import Data.Foldable import Data.Foldable
import Prettyprinter.Render.Terminal
data ShowObject = ShowRef RepoRef | ShowConfig data ShowObject = ShowRef RepoRef | ShowConfig
@ -26,20 +27,20 @@ showRef h = do
showRefs :: MonadIO m => App m () showRefs :: MonadIO m => App m ()
showRefs = do showRefs = do
liftIO $ print $ pretty "References:" liftIO $ putDoc $ line <> green "References:" <> section
runListRefs runListRefs
showConfig :: MonadIO m => App m () showConfig :: MonadIO m => App m ()
showConfig = liftIO do showConfig = liftIO do
ConfigPathInfo{..} <- getConfigPathInfo ConfigPathInfo{..} <- getConfigPathInfo
cfg <- readFile configFilePath cfg <- readFile configFilePath
print $ "Config file location:" <> line <> pretty configFilePath <> line putDoc $ green "Config file location:" <> section <> pretty configFilePath <> section
print $ "Config contents:" <> line <> pretty cfg putDoc $ green "Config contents:" <> line <> pretty cfg
showSummary :: MonadIO m => App m () showSummary :: MonadIO m => App m ()
showSummary = do showSummary = do
showRefs showRefs
liftIO $ print $ pretty "" liftIO $ putDoc section
showConfig showConfig
runShow :: MonadIO m => Maybe ShowObject -> App m () runShow :: MonadIO m => Maybe ShowObject -> App m ()

View File

@ -52,7 +52,7 @@ import System.IO.Unsafe (unsafePerformIO)
import Data.Cache qualified as Cache import Data.Cache qualified as Cache
import Control.Concurrent.Async import Control.Concurrent.Async
import System.Environment import System.Environment
import Control.Monad.Catch import Prettyprinter.Render.Terminal
instance MonadIO m => HasCfgKey ConfBranch (Set String) m where instance MonadIO m => HasCfgKey ConfBranch (Set String) m where
key = "branch" key = "branch"
@ -464,3 +464,9 @@ loadCredentials fp = do
pure () pure ()
green = annotate (color Green)
yellow = annotate (color Yellow)
section = line <> line

View File

@ -208,9 +208,6 @@ runExport :: forall m . (MonadIO m, MonadCatch m, HasProgress (App m))
=> Maybe FilePath -> RepoRef -> App m () => Maybe FilePath -> RepoRef -> App m ()
runExport fp h = do runExport fp h = do
let green = annotate (color Green)
let yellow = annotate (color Yellow)
let section = line <> line
liftIO $ putDoc $ liftIO $ putDoc $
line line

View File

@ -10,6 +10,7 @@ import HBS2.Git.Local.CLI
import Data.Functor import Data.Functor
import Data.Text qualified as Text import Data.Text qualified as Text
import Data.Traversable import Data.Traversable
import Prettyprinter.Render.Terminal
data AsRemoteEntry = AsRemoteEntry data AsRemoteEntry = AsRemoteEntry
{ remoteName :: Text, { remoteName :: Text,
@ -56,11 +57,11 @@ runListRefs = do
} }
) )
let header = let header =
fill remoteNameColWidth "Name" fill remoteNameColWidth (green "Name")
<+> fill remoteURLColWidth "URL" <+> fill remoteURLColWidth (green "URL")
<+> fill remoteRefValueColWidth "Reference value" <+> fill remoteRefValueColWidth (green "Reference value")
liftIO $ print header liftIO $ putDoc $ header <> line
liftIO $ print $ vcat $ pretty <$> remoteEntries liftIO $ putDoc $ vcat $ pretty <$> remoteEntries
where where
isHbs2 (_, b) = Text.isPrefixOf hbs2Prefix b isHbs2 (_, b) = Text.isPrefixOf hbs2Prefix b