lentil 0.1.1.2 → 0.1.1.3
raw patch · 14 files changed
+165/−111 lines, 14 files
Files
- changes.txt +6/−0
- doc/usr/page.rst +2/−0
- issues.txt +30/−16
- lentil.cabal +2/−2
- src/Lentil.hs +0/−53
- src/Lentil/Args.hs +0/−1
- src/Lentil/Export.hs +1/−3
- src/Lentil/Parse/Issue.hs +38/−13
- src/Lentil/Parse/Source.hs +5/−5
- src/Lentil/Print.hs +6/−4
- src/Lentil/Query.hs +3/−4
- src/Main.hs +52/−0
- test/Lentil/Parse/IssueSpec.hs +14/−10
- test/Tests.hs +6/−0
changes.txt view
@@ -1,3 +1,9 @@+0.1.1.3+-------++- Released Mon 15 Jun 2015 23:29:49 CEST+- fixmes and xxx issues now get a free [fixme]/[xxx] tag+ 0.1.1.2 -------
doc/usr/page.rst view
@@ -128,6 +128,8 @@ Tags are single words which are useful to catalogue and identify issues. Use them aplenty as they will make slicing and dicing your issue-base a breeze.+Since the semantic of ``FIXME`` and ``XXX`` is specific (in respect to the+usual ``TODO``), they are automatically added as a tag. As now lentil parses:
issues.txt view
@@ -7,20 +7,32 @@ haskell and stuff [feature:intermediate] 16 html report, come hlint [feature:advanced] 17 symlinks? [feature:intermediate]- 18 le ricerche è meglio che siano case unsensitive [feature:basic]- 19 check --output pretty, there are trailing white spaces [bug] [u:1]- 20 test con 7.6.3 [feature:basic] [test]- 21 todo/fixmes in different sections [request] [u:3]- -src/Lentil.hs- 13 compile with O2? [refactor]- 36 clean these nested ifs up [lint]+ 18 check --output pretty, there are trailing white spaces [bug] [u:1]+ 19 test con 7.6.3 [feature:basic] [test]+ 20 todo/fixmes in different sections [request] [u:3]+ 21 linux kernel, lentil si inceppa su dei caratteri [bug]+ 22 da cabal a hpack [u:1] [feature:advanced]+ 23 ad oggi veramente lento [u:2] [refactor]+ 24 list 'ok' tags somehow? put them in doc? [doc] [design]+ 25 sm: issue numbers is valuable [design] [request]+ 26 sm: have a way to link to discussion/history of issue [design]+ [request]+ 27 sm: 1. lentil autogenerates numbers where missing adding tags, 2.+ creates an associated numbered file in .issues/, displays+ associated notes written in those files is asked, 3. even update+ them when there is a source change. (4) these files could be+ webserved when they want something linkable. Vedi comments in+ doc/dev/issues.txt [design] [request]+ 33 chickpea, lentil's brother. Two commands, add number to numberless+ tag (#1212 or something), create a mini db with those issues, which+ automatically updated and you can even write stuff in there. O+ maybe you can even add lentil, chickpea and quinoa. Vedi more in+ doc/dev/issues.txt [design] src/Lentil/Args.hs- 23 show help option in lentil short help [feature:intermediate]- 24 disambiguation optparse-applicative [feature:intermediate]- 25 help as lentil PATH [ PATH... ] [ OPTIONS ] [feature:intermediate]- 90 uncomment and implement sorting [feature:intermediate]+ 23 disambiguation optparse-applicative [feature:intermediate]+ 24 help as lentil PATH [ PATH... ] [ OPTIONS ] [feature:intermediate]+ 89 uncomment and implement sorting [feature:intermediate] src/Lentil/File.hs 49 combine funziona su windows? [feature:intermediate]@@ -44,14 +56,16 @@ 83 lint program parser [lint] 87 manyTill1 broken? occhio che al primon on chiama ed! [test] 102 ugly parens [lint] [refactor]- 115 add more langparsers [feature:intermediate]- 116 fallo che sia estensibile e leggibile a compilazione [design] [u:3]+ 116 add langparsers che sia estensibile e leggibile a compilazione+ [u:3] 155 ugly hack to allow tODOs to be parseable even in first line. This is coupled with another hack in parser `issue` (another module). [refactor] [lint] [duct] -src/Lentil/Query.hs- 21 filtering case unsensitive? [test]+src/Lentil/Print.hs+ 43 colours are bad for unix philosophy, remove them? hlint manages to+ get a colorised output when ran alone but not when piped to less,+ how? [design] test/Lentil/ArgsSpec.hs 12 can't test lOpts, need to make a runner and a validator on the
lentil.cabal view
@@ -1,5 +1,5 @@ name: lentil-version: 0.1.1.2+version: 0.1.1.3 synopsis: frugal issue tracker description: minumum effort, cohesive issue tracker based on ubiquitous @TODO@s and @FIXME@s conventions.@@ -33,7 +33,7 @@ executable lentil- main-is: Lentil.hs+ main-is: Main.hs build-depends: base >=4.7 && <4.9, optparse-applicative >=0.11 && <0.12, regex-tdfa >=1.2 && <1.3, natural-sort >=0.1 && <0.2, parsec >=3.1 && <3.2, filepath >=1.3 && <1.5,
− src/Lentil.hs
@@ -1,53 +0,0 @@-import Lentil.Types-import Lentil.Args-import Lentil.File-import Lentil.Print-import Lentil.Query-import Lentil.Export--import Options.Applicative--import qualified Data.Maybe as M-import Data.Monoid---- TODO: compile with O2? [refactor]--main :: IO ()-main = execParser opts >>= runLentil- where opts = info (helpOvert <*> lOpts <* version)- ( fullDesc <>- header "lentil - a frugal issue tracker" )---- overt help text (even in condensed help)-helpOvert :: Parser (a -> a)-helpOvert = abortOption ShowHelpText $ mconcat [ long "help",- short 'h',- help "Show this help text" ]--version = infoOption versionCopy ( long "version" <>- short 'v' <>- help "show version and copyright info" )- where- versionCopy = "lentil - a frugal issue tracker, version 0.1.1.2\n\- \(C) 2015 Francesco Ariis - http://www.ariis.it\n\- \released under the GNU General Public License 3"---runLentil :: LOptions -> IO ()-runLentil lo = uncurry findIssues (loInExcl lo) >>= \is -> -- grab issues- let fil = filterAnd (loFilters lo) is -- filtered- ord = chainSorts fil (loSort lo) in -- ordered-- case loOutFile lo of-- -- std output- Nothing -> case loFormat lo of- Csv -> putStrLn (issues2CSV is)- Pretty -> putStrLn (ppIssues True ord)- TagPop -> putStrLn (ppPopularity True is)-- Just fp -> case loFormat lo of- Csv -> writeFile fp (issues2CSV is)- Pretty -> writeFile fp (ppIssues False ord)- TagPop -> writeFile fp (ppPopularity False is)-
src/Lentil/Args.hs view
@@ -20,7 +20,6 @@ -- TYPES -- ----------- --- TODO: show help option in lentil short help [feature:intermediate] -- TODO: disambiguation optparse-applicative [feature:intermediate] -- TODO: help as lentil PATH [ PATH... ] [ OPTIONS ] [feature:intermediate]
src/Lentil/Export.hs view
@@ -12,9 +12,7 @@ import Text.CSV import Lentil.Types -import qualified Data.List as L - --------------- -- FUNCTIONS -- ---------------@@ -31,5 +29,5 @@ ----------------- tags2String :: [Tag] -> String-tags2String ts = L.intercalate " " (map tagString ts)+tags2String ts = unwords (map tagString ts)
src/Lentil/Parse/Issue.hs view
@@ -37,8 +37,22 @@ -- file we are parsing data ParState = ParState { psPath :: FilePath } +-- issue flagword+data FlagWord = Todo | Fixme | Xxx deriving (Show, Enum, Eq) +fw2s :: FlagWord -> String+fw2s Todo = "todo"+fw2s Fixme = "fixme"+fw2s Xxx = "xxx" +s2fw :: String -> FlagWord+s2fw s = case map C.toLower s of+ "todo" -> Todo+ "fixme" -> Fixme+ "xxx" -> Xxx+ e -> error ("unrecognised fw: " ++ e)++ --------------- -- PRIMITIVE -- ---------------@@ -99,17 +113,20 @@ ------------- -- optional ws + flagwords (case unsensitive) + optional ':' ++ optional1 ws-incipit :: ParIssue ()-incipit = () <$ ( char '\n' *>- spaces *>- choice (map ciString flagWords) *>- optional (char ':') *>- many1 (char ' ') )+incipit :: ParIssue FlagWord+incipit = char '\n' *> spaces >>+ fwpar >>= \fw ->+ optional (char ':') >>+ many1 (char ' ') >> -- fixme usa spaces non ' '+ return fw <?> "incipit"+ where+ flagWords = map fw2s (enumFrom Todo) + fwpar = choice (map ciString flagWords) >>=+ return . s2fw+ -- TODO: allow tags in before description? [doc] [design]-flagWords :: [String]-flagWords = ["TODO", "FIXME", "XXX"] ------------@@ -122,13 +139,21 @@ -- ended optionally by some tags (No t/f? End by whiteline or eof or -- another TODO). issue :: ParIssue Issue-issue = (Issue <$> fmap psPath getState- <*> (incipit *> fmap sourceLine getPosition)- <*> freeText- <*> option [] (try tags))+issue = (mkIssue <$> incipit+ <*> fmap psPath getState+ <*> (fmap sourceLine getPosition)+ <*> freeText+ <*> option [] (try tags)) <?> "issue"+ where+ mkIssue fw fp ln ds tgs = Issue fp ln ds (addTag fw tgs) + -- todo incipit should return FlagWord, not a string [refactor]+ addTag Todo tgs = tgs+ addTag fw tgs = (Tag $ fw2s fw) : tgs ++ -- any text. Since tags/fields at the end of the issue are optional, we need -- a way to delimit this. Delimiters are: eof, tags/fields, blank line freeText :: ParIssue Description@@ -149,7 +174,7 @@ -- parses a number of issues from a given line-of-text issues :: ParIssue [Issue] issues = getPosition >>= \p -> -- horrible hack, search for [duct] for expl-- setPosition (setSourceLine p (0)) >> -- anation+ setPosition (setSourceLine p 0) >> -- anation many (try $ manyTill anyChar (lookAhead $ try incipit) *> issue) <?> "issues"
src/Lentil/Parse/Source.hs view
@@ -74,7 +74,7 @@ -- every unambiguous symbol (init comments, listring char) posts = psLineComms ps ++ map fst (psBlockComms ps) ++- (map (:[]) $ psStringLits ps)+ map (:[]) (psStringLits ps) -- ambiguous symbols (pall'aaa'foo is valid haskell identifier, -- so it should stay here@@ -98,9 +98,9 @@ source ps@(ParSyntax lc bc sl cl) = choice (map (try . lineComment) lc) -- line comment <|> choice (map (try . blockComment) bc) -- block comment- <|> (choice (map (onlynl . try . litString) sl))- <|> ("" <$ (choice (map (try . litChar) cl))) -- todo ugly parens [lint] [refactor]- <|> (onlynl $ program ps)+ <|> choice (map (onlynl . try . litString) sl)+ <|> ("" <$ choice (map (try . litChar) cl)) -- todo ugly parens [lint] [refactor]+ <|> onlynl (program ps) <?> "source file" where onlynl a = fmap (filter (== '\n')) a @@ -114,7 +114,7 @@ -------------- -- TODO: add langparsers che sia estensibile e leggibile--- a compilazione [design] [u:3]+-- a compilazione [u:3] langParser :: String -> Maybe (ParSource String) langParser fp | ext `elem` [".hs", ".lhs"] = Just haskell
src/Lentil/Print.hs view
@@ -32,15 +32,17 @@ -- Bool: wheter or not to use colours in rendering myRender :: Bool -> Doc -> String myRender col d = ($ "") . displayS . renderPretty 1 75 $ d'- where d' | col == True = d- | otherwise = plain d+ where d' | col = d+ | otherwise = plain d ------------------ -- PRETTY PRINT -- ------------------ --- TODO: colours are bad for unix philosophy, remove them? [design]+-- TODO: colours are bad for unix philosophy, remove them? hlint+-- manages to get a colorised output when ran alone but not when+-- piped to less, how? [design] data TagCol = Red | Blue deriving (Eq) ppTag :: TagCol -> Tag -> Doc ppTag c t = col (char openDel) <> string (tagString t) <>@@ -78,7 +80,7 @@ -- tagpop pp report ppPopularity :: Bool -> [Issue] -> String ppPopularity col is = myRender col $ text "Tags popularity:" PP.<$>- vsep (ppPops) -- PP.<$> (string "")+ vsep ppPops -- PP.<$> (string "") where listpop = tagPop is
src/Lentil/Query.hs view
@@ -18,7 +18,6 @@ type RegExp = String --- TODO: filtering case unsensitive? [test] --------------- -- FILTERING --@@ -58,7 +57,7 @@ -- sequences sorting chainSorts :: [Issue] -> [[Issue] -> [Issue]] -> [Issue] chainSorts is [] = is-chainSorts is (s:ss) = concatMap (flip chainSorts ss) $ L.group (s is)+chainSorts is (s:ss) = concatMap (`chainSorts` ss) $ L.group (s is) -- given a particular accessor and a sort order, sorts issues sortIssues :: (NS.NaturalSort a) => (Issue -> a) -> SortOrder ->@@ -94,7 +93,7 @@ -- tag popularity tagPop :: [Issue] -> [(Tag, Int)]-tagPop is = reverse . L.sortBy (compare `F.on` snd) .- map (\l -> (head l, length l)) . L.group .+tagPop is = reverse . L.sortBy (compare `F.on` snd) . -- flip avoids reverse+ map (\l -> (head l, length l)) . L.group . -- but not the same L.sort . concatMap iTags $ is
+ src/Main.hs view
@@ -0,0 +1,52 @@+import Lentil.Types+import Lentil.Args+import Lentil.File+import Lentil.Print+import Lentil.Query+import Lentil.Export++import Options.Applicative++import qualified Data.Maybe as M+import Data.Monoid+++main :: IO ()+main = execParser opts >>= runLentil+ where opts = info (helpOvert <*> lOpts <* version)+ ( fullDesc <>+ header "lentil - a frugal issue tracker" )++-- overt help text (even in condensed help)+helpOvert :: Parser (a -> a)+helpOvert = abortOption ShowHelpText $ mconcat [ long "help",+ short 'h',+ help "Show this help text" ]++version = infoOption versionCopy ( long "version" <>+ short 'v' <>+ help "show version and copyright info" )+ where+ versionCopy = "\nlentil - a frugal issue tracker, version 0.1.1.3\n\+ \(C) 2015 Francesco Ariis - http://www.ariis.it\n\+ \released under the GNU General Public License 3\n"+++runLentil :: LOptions -> IO ()+runLentil lo = uncurry findIssues (loInExcl lo) >>= \is -> -- grab issues+ let fil = filterAnd (loFilters lo) is -- filtered+ ord = chainSorts fil (loSort lo) in -- ordered++ case loOutFile lo of++ -- std output+ Nothing -> case loFormat lo of+ Csv -> putStrLn (issues2CSV is)+ Pretty -> putStrLn (ppIssues True ord)+ TagPop -> putStrLn (ppPopularity True is)++ Just fp -> case loFormat lo of+ Csv -> writeFile fp (issues2CSV is)+ Pretty -> writeFile fp (ppIssues False ord)+ TagPop -> writeFile fp (ppPopularity False is)+
test/Lentil/Parse/IssueSpec.hs view
@@ -56,19 +56,19 @@ describe "incipit" $ do it "parses the initial section of an issue, returns nothing" $- do sp incipit "\nTODO: " `shouldBe` Just ()- sp incipit "\nFIXME: " `shouldBe` Just ()- sp incipit "\nXXX: " `shouldBe` Just ()+ do sp incipit "\nTODO: " `shouldBe` Just Todo+ sp incipit "\nFIXME: " `shouldBe` Just Fixme+ sp incipit "\nXXX: " `shouldBe` Just Xxx it "doesn't work without previous newline" $ sp incipit "\nTODO:some" `shouldBe` Nothing it "doesn't work if you don't add a space after :" $ sp incipit "\nTODO:some" `shouldBe` Nothing it "does allow you to omit the :" $- sp incipit "\nxxx some" `shouldBe` Just ()+ sp incipit "\nxxx some" `shouldBe` Just Xxx it "is case unsensitive in flag-word" $- sp incipit "\ntOdO some" `shouldBe` Just ()+ sp incipit "\ntOdO some" `shouldBe` Just Todo it "allows whitespace before the todo" $- sp incipit "\n fixme some" `shouldBe` Just ()+ sp incipit "\n fixme some" `shouldBe` Just Fixme it "doesn't allow anything else before flag-words" $ sp incipit "\nso fixme someday" `shouldBe` Nothing it "fails if we are not at the beginning of line" $@@ -103,7 +103,8 @@ describe "issue" $ do it "parses an issue" $ sp issue "\n fixMe this is it [t] [f:w]"- `shouldBe` (Just $ Issue "<f>" 2 "this is it" [Tag "t", Tag "f:w"])+ `shouldBe` (Just $ Issue "<f>" 2 "this is it"+ [Tag "fixme", Tag "t", Tag "f:w"]) it "fails if were are not at beginning of a line" $ sp issue "fixMe this is it [t] [f:w]" `shouldBe` Nothing@@ -116,6 +117,9 @@ it "doesn't accept a lone (naked) todo" $ sp issue "\ntodo\n" `shouldBe` Nothing+ it "issues declared with fixme get a free [fixme] tag" $+ sp issue "\nfixme blah\n"+ `shouldBe` (Just $ Issue "<f>" 2 "blah" [Tag "fixme"]) describe "issues" $ do it "parses multiple issues" $@@ -131,7 +135,7 @@ let fp = "test/test-files/lang-comm/test.txt" in issueFinder [fp] >>= \i -> i `shouldBe` [Issue fp 1 "palla" [],- Issue fp 3 "beta" [],- Issue fp 4 "gamma" [],- Issue fp 6 "qqq" [Tag "bug"]]+ Issue fp 3 "beta" [Tag "fixme"],+ Issue fp 4 "gamma" [Tag "xxx"],+ Issue fp 6 "qqq" [Tag "fixme", Tag "bug"]]
test/Tests.hs view
@@ -1,2 +1,8 @@ {-# OPTIONS_GHC -F -pgmF hspec-discover #-} +-- TODO: http://hackage.haskell.org/package/nanospec-0.2.1/docs/Test-Hspec.html+-- use this? [refactor]++-- TODO: http://hackage.haskell.org/package/mockery-0.3.0/docs/Test-Mockery-Directory.html+-- instead of folder use this? [refactor]+