aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-17 12:34:58 +0200
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-10-17 12:34:58 +0200
commit8c374417d9ca0ee4c4d75ee171d8b4e2f150bf78 (patch)
tree1c28eb3ba9cf4e8ef088e622b1ea3546c7332aff /app/Main.hs
parent08f75854a59c2ebc4cf6685d5d5f7041d7ef29e3 (diff)
add `log` command
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs36
1 files changed, 35 insertions, 1 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 28632ad..a7901bd 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -453,7 +453,7 @@ import Data.Text qualified as T
import Data.Text.Lazy qualified as LT
import Data.Text.Lazy.IO qualified as LT
import Data.Time.Clock (UTCTime (utctDay))
-import History (listIssues)
+import History (IssueEvent (..), listEvents, listIssues)
import Issue (Issue (..))
import Issue qualified as I
import Issue.Filter (Filter)
@@ -545,6 +545,7 @@ data Command
filters :: [Filter],
sort :: [Sort]
}
+ | Log
| Show
{ id :: String
}
@@ -555,6 +556,8 @@ cmd =
O.hsubparser . mconcat $
[ O.command "list" . O.info listCmd $
O.progDesc "List all issues",
+ O.command "log" . O.info logCmd $
+ O.progDesc "Show a log of all issues",
O.command "show" . O.info showCmd $
O.progDesc "Show details of all issues"
]
@@ -566,6 +569,10 @@ listCmd =
<*> I.filterArg
<*> I.sortArg
+logCmd :: O.Parser Command
+logCmd =
+ pure Log
+
showCmd :: O.Parser Command
showCmd =
Show
@@ -625,6 +632,33 @@ main = do
]
)
issues
+ Options {colorize, noPager, width, command = Log} -> do
+ -- TODO Reconcile log
+ --
+ -- When viewing the log I am confused by
+ --
+ -- (1) lots of sequential commits "changing" the same one issue, but no
+ -- others,
+ -- (2) having unknown hashes interleaved
+ --
+ -- I would assume changes to be less frequent, or, if no changes are
+ -- considered changes, the log output sorted by hashes (and not
+ -- commits?). I would expect only the first commit hash to be unknown.
+ --
+ -- Thoughts? :-)
+ es <- concat <$> listEvents
+ putDoc colorize noPager width . P.vsep $
+ map
+ ( \e ->
+ let shortHash = P.annotate (P.color P.Yellow) . P.pretty $ maybe "UNKNOWN" (T.take 7) e.hash
+ kwd = P.annotate (P.color P.Green) . P.pretty . T.pack
+ title issue = P.annotate (P.color P.Blue) . P.annotate P.bold $ P.pretty issue.title
+ in case e of
+ IssueCreated {issue} -> shortHash <+> kwd "created" <+> title issue
+ IssueChanged {issue} -> shortHash <+> kwd "changed" <+> title issue
+ IssueDeleted {} -> shortHash <+> kwd "deleted"
+ )
+ es
Options {colorize, width, command = Show {id}} -> do
issues <- listIssues [] [] []
case find ((==) (Just id) . I.id) issues of