diff options
Diffstat (limited to 'app/Main.hs')
-rw-r--r-- | app/Main.hs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/app/Main.hs b/app/Main.hs index fe031af..52a316d 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -317,6 +317,7 @@ module Main where +import Comment qualified as G import Control.Applicative ((<|>)) import Data.Function ((&)) import Data.List (find, intersperse) @@ -420,6 +421,9 @@ data Command | Log { patch :: Bool } + | Open + { id :: String + } | Search { pattern :: R.RE, closed :: Bool, @@ -438,6 +442,8 @@ cmd = O.progDesc "List all issues", O.command "log" . O.info logCmd $ O.progDesc "Show a log of all issues", + O.command "open" . O.info openCmd $ + O.progDesc "Open file containing an issue", O.command "search" . O.info searchCmd $ O.progDesc "List issues matching a pattern", O.command "show" . O.info showCmd $ @@ -469,6 +475,11 @@ searchCmd = <*> closedArg <*> detailedArg +openCmd :: O.Parser Command +openCmd = + Open + <$> idArg + showCmd :: O.Parser Command showCmd = Show @@ -578,6 +589,13 @@ main = do Options {colorize, noPager, width, command = Tags} -> do issues <- (.issues) <$> H.getIssues putDoc colorize noPager width $ concatMap (.tags) issues + Options {command = Open {id}} -> do + issues <- (.issues) <$> H.getIssues + issue <- + case M.lookup (T.pack id) issues of + Nothing -> die (printf "no issue with id `%s'\n" id) + Just issue -> pure issue + sh_ (proc "${EDITOR-vi} +% -- %" issue.startPoint.row issue.file) Options {colorize, noPager, width, command = Search {pattern, closed, detailed}} -> do issues <- I.applyClosed closed |