aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/Main.hs88
-rwxr-xr-xsrc/extract.sh49
2 files changed, 75 insertions, 62 deletions
diff --git a/app/Main.hs b/app/Main.hs
index 39387cc..66b0323 100644
--- a/app/Main.hs
+++ b/app/Main.hs
@@ -1,6 +1,51 @@
+{-# LANGUAGE OverloadedRecordDot #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PartialTypeSignatures #-}
+-- TODO Add support for ammendments
+--
+-- The user can ammend more information to an issue which is located at
+-- a different place by referencing the issue's id. Example:
+--
+-- ```bash
+-- #!/usr/bin/env bash
+--
+-- set -efu
+--
+-- ls -al
+-- # TODO Original issue
+-- #
+-- # @id original-issue
+--
+-- ls
+-- # @original-issue more information on the issue
+-- ```
+
+-- TODO Only one issue per comment block
+--
+-- Only the first TODO/FIXME inside a comment block should be considered
+-- as the start of an issue.
+--
+-- TODO Add support for other keywords
+--
+-- Additionally to TODO, also FIXME should start an issue. There might
+-- be more interesting keywords.
+
+-- TODO Add tags
+--
+-- Users can add tags inside issue title and description. Tags are slugs
+-- and start with @
+--
+-- @assigned aforemny
+
+-- TODO Add filter by tags
+--
+-- Users can filter issues for tags with the option -t/--tag @tag.
+--
+-- @assigned kirchner@posteo.de
+
+-- TODO Generate and show hash for each issue
+
module Main where
import Control.Exception (Exception, catch, throw)
@@ -64,7 +109,14 @@ main = do
hPutStrLn stderr error
exitWith (ExitFailure 1)
)
- mapM_ putStrLn $ fmap file $ concat issues
+ let issuesWithMarker = issues
+ issuesWithTags = issuesWithMarker
+ issuesFilteredByTags = issuesWithTags
+ mapM_ printIssue $ concat issues
+
+printIssue :: TreeGrepperResult -> IO ()
+printIssue treeGrepperResult =
+ putStrLn $ treeGrepperResult.file
data UnknownFileExtension = UnknownFileExtension
{ extension :: String
@@ -118,6 +170,10 @@ getIssues :: String -> IO [TreeGrepperResult]
getIssues filename =
let extension = F.takeExtension filename
treeGrepperLanguage =
+ -- TODO Add support for all tree-grepper supported files
+ --
+ -- tree-grepper supported files can be listed through `tree-grepper
+ -- --languages`.
case extension of
".elm" -> "elm"
".nix" -> "nix"
@@ -135,18 +191,24 @@ getIssues filename =
throw (InvalidTreeGrepperResult error)
Right treeGrepperResult ->
treeGrepperResult
- in fmap (decode . snd) $
- P.readProcessStdout
- ( String.fromString
- ( "tree-grepper --query '"
- ++ treeGrepperLanguage
- ++ "' '"
- ++ treeGrepperQuery
- ++ "' --format json '"
- ++ filename
- ++ "'"
- )
- )
+ in fmap (map fixTreeGrepper) $
+ fmap (decode . snd) $
+ P.readProcessStdout
+ ( String.fromString
+ ( "tree-grepper --query '"
+ ++ treeGrepperLanguage
+ ++ "' '"
+ ++ treeGrepperQuery
+ ++ "' --format json '"
+ ++ filename
+ ++ "'"
+ )
+ )
+
+fixTreeGrepper :: TreeGrepperResult -> TreeGrepperResult
+fixTreeGrepper =
+ -- TODO implement match merging
+ id
getFiles :: IO [String]
getFiles =
diff --git a/src/extract.sh b/src/extract.sh
index 07346fc..cd5cb67 100755
--- a/src/extract.sh
+++ b/src/extract.sh
@@ -1,58 +1,9 @@
#!/usr/bin/env bash
-# TODO Add support for ammendments
-#
-# The user can ammend more information to an issue which is located at
-# a different place by referencing the issue's id. Example:
-#
-# ```bash
-# #!/usr/bin/env bash
-#
-# set -efu
-#
-# ls -al
-# # TODO Original issue
-# #
-# # @id original-issue
-#
-# ls
-# # @original-issue more information on the issue
-# ```
-
-# TODO Only one issue per comment block
-#
-# Only the first TODO/FIXME inside a comment block should be considered
-# as the start of an issue.
-
-# TODO Add support for other keywords
-#
-# Additionally to TODO, also FIXME should start an issue. There might
-# be more interesting keywords.
-
-# TODO Add tags
-#
-# Users can add tags inside issue title and description. Tags are slugs
-# and start with @
-#
-# @assigned aforemny
-
-# TODO Add filter by tags
-#
-# Users can filter issues for tags with the option -t/--tag @tag.
-#
-# @assigned kirchner@posteo.de
-
-# TODO Generate and show hash for each issue
-
-
set -efu
git ls-files --cached --exclude-standard --other |
while read -r input_file; do
- # TODO Add support for all tree-grepper supported files
- #
- # tree-grepper supported files can be listed through `tree-grepper
- # --languages`.
ext=
case $input_file in
*.elm) ext="elm" ;;