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

View File

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