From 53044dc28aefcc0572dc2416d58052035d5eb846 Mon Sep 17 00:00:00 2001 From: Fabian Kirchner Date: Mon, 2 Oct 2023 16:36:40 +0200 Subject: add issues to new code --- app/Main.hs | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 13 deletions(-) (limited to 'app') 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 = -- cgit v1.2.3