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

@ -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 ()

View File

@ -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

View File

@ -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

View File

@ -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