aboutsummaryrefslogtreecommitdiffstats
path: root/app/Main.hs
diff options
context:
space:
mode:
Diffstat (limited to 'app/Main.hs')
-rw-r--r--app/Main.hs42
1 files changed, 36 insertions, 6 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 06327c4..26e3401 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -483,7 +483,8 @@ data Command
{ files :: [String],
filters :: [Filter],
sort :: [Sort],
- group :: Maybe T.Text
+ group :: Maybe T.Text,
+ closed :: Bool
}
| Log
| Show
@@ -513,6 +514,7 @@ listCmd =
<*> I.filterArg
<*> I.sortArg
<*> I.groupArg
+ <*> closedArg
logCmd :: O.Parser Command
logCmd =
@@ -531,6 +533,13 @@ tagsCmd =
filesArg :: O.Parser [String]
filesArg = O.many (O.strArgument (O.metavar "FILE" <> O.action "file"))
+closedArg :: O.Parser Bool
+closedArg =
+ O.switch
+ ( O.long "closed"
+ <> O.help "Show closed issues."
+ )
+
idArg :: O.Parser String
idArg =
O.strArgument
@@ -555,9 +564,16 @@ main :: IO ()
main = do
settings <- readSettings
O.execParser (O.info (options <**> O.helper) O.idm) >>= \case
- Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Just group}} -> do
+ Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Just group, closed}} -> do
let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files
- ungroupedIssues <- applySorts sort . applyFilters filters . filter withinPath . trd3 . last <$> getHistory
+ ungroupedIssues <-
+ applySorts sort
+ . applyFilters filters
+ . filter withinPath
+ . applyClosed closed
+ . trd3
+ . last
+ <$> getHistory
let groupedIssues = I.groupIssuesBy group ungroupedIssues
putDoc colorize noPager width
. P.vsep
@@ -595,9 +611,16 @@ main = do
)
)
(M.toList groupedIssues)
- Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Nothing}} -> do
+ Options {internalTags, colorize, noPager, width, command = List {sort, filters, files, group = Nothing, closed}} -> do
let withinPath issue = if null files then True else any (\file -> file `isPrefixOf` issue.file) files
- issues <- applySorts sort . applyFilters filters . filter withinPath . trd3 . last <$> getHistory
+ issues <-
+ applySorts sort
+ . applyFilters filters
+ . filter withinPath
+ . applyClosed closed
+ . trd3
+ . last
+ <$> getHistory
putDoc colorize noPager width . P.vsep $
map
( \issue ->
@@ -643,7 +666,11 @@ main = do
Just issue -> pure issue
let meta = I.getMeta issues issue
let s =
- (LT.fromStrict (T.intercalate " " issue.markers) <> " " <> LT.fromStrict issue.title)
+ ( (if issue.closed then "**(CLOSED)** " else "")
+ <> LT.fromStrict (T.intercalate " " issue.markers)
+ <> " "
+ <> LT.fromStrict issue.title
+ )
<> maybe "" (("\n\n" <>) . LT.fromStrict) issue.description
<> LT.intercalate "\n" (map ((("***\n" :: LT.Text) <>) . LT.fromStrict) issue.comments)
if edit
@@ -734,6 +761,9 @@ main = do
)
tagsAndValues
+applyClosed :: Bool -> [Issue] -> [Issue]
+applyClosed closed = filter (\issue -> closed || not issue.closed)
+
prettyTags :: [I.Tag] -> [P.Doc P.AnsiStyle]
prettyTags =
map