mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-11 10:35:57 +03:00
Add human formatting
This commit is contained in:
parent
90f4a817eb
commit
f239b581f0
@ -555,7 +555,7 @@ numberedColumnNHeader ::
|
||||
[[Pretty ColorText]] ->
|
||||
Pretty ColorText
|
||||
numberedColumnNHeader headers rows =
|
||||
let numbers = "" : (hiBlack . shown <$> [1 :: Int ..])
|
||||
let numbers = ([1 :: Int ..] <&> \n -> hiBlack (shown n <> "."))
|
||||
in columnNHeader ("" : headers) (zipWith (:) numbers rows)
|
||||
|
||||
-- Opinionated `numbered` that uses bold numbers in front
|
||||
|
@ -27,6 +27,7 @@ dependencies:
|
||||
- exceptions
|
||||
- extra
|
||||
- filepath
|
||||
- friendly-time
|
||||
- generic-lens
|
||||
- haskeline
|
||||
- http-client >= 0.7.6
|
||||
|
@ -22,7 +22,8 @@ import qualified Data.Set as Set
|
||||
import Data.Set.NonEmpty (NESet)
|
||||
import qualified Data.Text as Text
|
||||
import qualified Data.Text.Encoding as Text
|
||||
import Data.Time.Format.ISO8601 (iso8601Show)
|
||||
import Data.Time (UTCTime, getCurrentTime)
|
||||
import Data.Time.Format.Human (humanReadableTime')
|
||||
import Data.Tuple (swap)
|
||||
import Data.Tuple.Extra (dupe)
|
||||
import qualified Network.HTTP.Types as Http
|
||||
@ -1398,11 +1399,12 @@ notifyUser dir o = case o of
|
||||
PatchInvolvesExternalDependents _ _ ->
|
||||
pure "That patch involves external dependents."
|
||||
ShowReflog [] -> pure . P.warnCallout $ "The reflog appears to be empty!"
|
||||
ShowReflog entries ->
|
||||
ShowReflog entries -> do
|
||||
now <- getCurrentTime
|
||||
pure $
|
||||
P.lines
|
||||
[ header,
|
||||
P.numberedColumnNHeader ["At", "Root Hash", "Action"] $ entries <&> renderEntry3Column
|
||||
P.numberedColumnNHeader ["When", "Action", "Root Hash"] $ entries <&> renderEntry3Column now
|
||||
]
|
||||
where
|
||||
header =
|
||||
@ -1432,9 +1434,9 @@ notifyUser dir o = case o of
|
||||
""
|
||||
]
|
||||
_ -> mempty
|
||||
renderEntry3Column :: Reflog.Entry ShortBranchHash Text -> [Pretty]
|
||||
renderEntry3Column (Reflog.Entry {time, rootCausalHash, reason}) =
|
||||
[P.green . P.string $ iso8601Show time, P.blue (prettySBH rootCausalHash), P.text reason]
|
||||
renderEntry3Column :: UTCTime -> Reflog.Entry ShortBranchHash Text -> [Pretty]
|
||||
renderEntry3Column now (Reflog.Entry {time, rootCausalHash, reason}) =
|
||||
[P.green . P.string $ humanReadableTime' now time, P.text reason, P.blue (prettySBH rootCausalHash)]
|
||||
StartOfCurrentPathHistory ->
|
||||
pure $
|
||||
P.wrap "You're already at the very beginning! 🙂"
|
||||
|
@ -116,6 +116,7 @@ library
|
||||
, exceptions
|
||||
, extra
|
||||
, filepath
|
||||
, friendly-time
|
||||
, generic-lens
|
||||
, haskeline
|
||||
, http-client >=0.7.6
|
||||
@ -226,6 +227,7 @@ executable cli-integration-tests
|
||||
, exceptions
|
||||
, extra
|
||||
, filepath
|
||||
, friendly-time
|
||||
, generic-lens
|
||||
, haskeline
|
||||
, http-client >=0.7.6
|
||||
@ -331,6 +333,7 @@ executable transcripts
|
||||
, exceptions
|
||||
, extra
|
||||
, filepath
|
||||
, friendly-time
|
||||
, generic-lens
|
||||
, haskeline
|
||||
, http-client >=0.7.6
|
||||
@ -440,6 +443,7 @@ executable unison
|
||||
, exceptions
|
||||
, extra
|
||||
, filepath
|
||||
, friendly-time
|
||||
, generic-lens
|
||||
, haskeline
|
||||
, http-client >=0.7.6
|
||||
@ -555,6 +559,7 @@ test-suite cli-tests
|
||||
, exceptions
|
||||
, extra
|
||||
, filepath
|
||||
, friendly-time
|
||||
, generic-lens
|
||||
, haskeline
|
||||
, here
|
||||
|
Loading…
Reference in New Issue
Block a user