aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-08 07:15:44 +0100
committerLibravatar Alexander Foremny <aforemny@posteo.de>2023-12-08 07:15:44 +0100
commit278e40659ced135ee14d82c3ccf1c0c6e90e85e1 (patch)
tree37509710b210a028b02ad6d7116c7ea876dcb474 /app
parent72ec82c49c0feaba61a9d8f5728b603dfa9a7a28 (diff)
feat: add `--detailed` to list
Diffstat (limited to 'app')
-rw-r--r--app/Main.hs36
1 files changed, 16 insertions, 20 deletions
diff --git a/app/Main.hs b/app/Main.hs
index fe802ad..da4ea6a 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -448,18 +448,14 @@ data Command
filters :: [I.Filter],
sort :: [I.Sort],
group :: Maybe T.Text,
- closed :: Bool
+ closed :: Bool,
+ detailed :: Bool
}
| Log
{ patch :: Bool
}
| Show
- { -- TODO Replace `anissue show` with `anissue list --detailed`
- --
- -- The `Show` command has recently been changed to allow showing multiple issues. However, filtering, soring, grouping, etc. is still lacking and would be useful for this mode.
- --
- -- Instead of copying over that functionality, and somehow explain that they are only sensible when omitting the optional `id` parameter, I would like to revert that change and add `--detailed` to `anissue list` which would show issues in the `Detailed` reporting style.
- id :: Maybe String,
+ { id :: String,
edit :: Bool
}
| Tags
@@ -486,6 +482,7 @@ listCmd =
<*> I.sortArg
<*> I.groupArg
<*> closedArg
+ <*> detailedArg
logCmd :: O.Parser Command
logCmd =
@@ -495,7 +492,7 @@ logCmd =
showCmd :: O.Parser Command
showCmd =
Show
- <$> O.optional idArg
+ <$> idArg
<*> editFlag
tagsCmd :: O.Parser Command
@@ -512,6 +509,13 @@ closedArg =
<> O.help "Show closed issues."
)
+detailedArg :: O.Parser Bool
+detailedArg =
+ O.switch
+ ( O.long "detailed"
+ <> O.help "Show issues detailed (as in show)."
+ )
+
idArg :: O.Parser String
idArg =
O.strArgument
@@ -557,7 +561,7 @@ main = do
<$> getHistory
let groupedIssues = I.groupIssuesByTag group ungroupedIssues
putDoc colorize noPager width (group, groupedIssues)
- Options {colorize, noPager, width, command = List {sort, filters, files, group = Nothing, closed}} -> do
+ Options {colorize, noPager, width, command = List {sort, filters, files, group = Nothing, closed, detailed}} -> do
issues <-
I.applySorts sort
. I.applyFilters filters
@@ -566,22 +570,14 @@ main = do
. (.issues)
<$> getHistory
putDoc colorize noPager width . (P.vsep . intersperse "") $
- map (P.render . P.Summarized) issues
+ map (if detailed then (P.render . P.Detailed) else (P.render . P.Summarized)) issues
Options {colorize, noPager, width, command = Log {patch}} -> do
es <- reverse . (.issueEvents) <$> getHistory
putDoc colorize noPager width . P.vsep $
if patch
then map (P.render . P.Detailed) es
else map (P.render . P.Summarized) es
- Options {colorize, noPager, width, command = Show {id = Nothing}} -> do
- issues <-
- I.applySorts []
- . I.applyFilters []
- . I.applyClosed False
- . (.issues)
- <$> getHistory
- putDoc colorize noPager width . P.vsep $ map (showIssue issues) issues
- Options {colorize, noPager, width, command = Show {id = Just id, edit}} -> do
+ Options {colorize, noPager, width, command = Show {id, edit}} -> do
issues <- (.issues) <$> getHistory
issue <-
case find ((==) id . T.unpack . I.id) issues of
@@ -590,7 +586,7 @@ main = do
if edit
then do
withSystemTempFile (printf "%s.md" id) $ \fp h -> do
- LT.hPutStr h (LT.fromStrict issue.rawText)
+ T.hPutStr h (issue.rawText)
hFlush h
hClose h
sh_ (proc "${EDITOR-vi} -- %" fp)