Nice table layout

This commit is contained in:
Julian Ospald 2020-01-31 23:18:45 +01:00
parent d3cd8bf333
commit dc7604024f
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
2 changed files with 16 additions and 13 deletions

View File

@ -31,6 +31,7 @@ import Options.Applicative
import Safe
import System.Console.Pretty
import System.Exit
import Text.Layout.Table
@ -123,12 +124,9 @@ lForkOpts = ListForkOptions <$> optional
main :: IO ()
main = do
let
run e = do
settings <-
exceptT
(\_ ->
die
let run e = do
settings <- exceptT
(\_ -> die
. color Red
$ "Could not get settings, make sure to run 'ghup config' first"
)
@ -163,13 +161,17 @@ main = do
Nothing -> pure Nothing
forks <- withExceptT show $ getForks mtime
let formatted = intercalate "\n" $ fmap
(\Repo {..} ->
(T.unpack . getUrl $ repoHtmlUrl) <> " " <> formatShow
(iso8601Format :: Format Day)
(utctDay $ fromJust repoUpdatedAt)
)
forks
let formatted =
gridString [column expand left def def
,column expand left def def]
$ fmap
(\Repo {..} ->
[ (T.unpack . getUrl $ repoHtmlUrl)
, formatShow (iso8601Format :: Format Day)
(utctDay $ fromJust repoUpdatedAt)
]
)
forks
liftIO $ putStrLn $ formatted
pure ()
case e of

View File

@ -55,6 +55,7 @@ executable ghup
, optparse-applicative ^>= 0.15
, pretty-terminal ^>= 0.1
, safe ^>= 0.3
, table-layout ^>= 0.8
, text ^>= 1.2
, time ^>= 1.9
, utf8-string ^>= 1.0