packages feed

lentil 0.1.5.0 → 0.1.6.0

raw patch · 17 files changed

+126/−73 lines, 17 files

Files

changes.txt view
@@ -1,3 +1,10 @@+0.1.6.0+-------++- Released Thu 01 Oct 2015 10:54:10 CEST+- Added support for Stack (patch by Francesco Mazzoli).+- Added extension aliases (request by Henning Thielemann).+ 0.1.5.0 ------- 
contributors.txt view
@@ -1,5 +1,6 @@ Francesco Ariis Larsen+Francesco Mazzoli Simon Michael Qptain Nemo Peter Simons
doc/usr/page.rst view
@@ -150,8 +150,19 @@ - nix source files (``.nix``) - plain text files (``.txt``) -Every other file-type will get ignored! Contact me if you need another-language to be added.+If you want a file type ``.xyz`` to be recognised as one in the list above,+invoke lentil with an extension alias:++::++  lentil . -a xyz%cpp++  # multiple aliases+  lentil . -a xyz%cpp -a qkw%js++but please *please* **please** contact me to have the extension(s) included+in `lentil` natively, as this will make the program more convenient to use.+  .. raw:: html 
issues.txt view
@@ -1,8 +1,3 @@-important: symlinks, windows, inceppa linux kernel, brogress bar, history-like sm suggests?, help as lentil PATH [PATH...], fast file programming,-extensible langparse,-henning newfiles- bin/make-bins.hs     20  auto search (global? cpp?) version number? [dist]  @@ -32,6 +27,9 @@     32  make it lazy in ouputting todos [refactor]     33  way to 'group' (section) output by tag [feature:advanced]     34  win (and mac?) builds [package] [u:3]+    35  Henning: don't output nothing on lentil xxx.cabal (maybe add 19+        skipped?) [request]+    36  Henning allow other extensions to be parsed [request]   src/Lentil/Args.hs     23  disambiguation optparse-applicative [feature:intermediate]@@ -53,8 +51,8 @@ src/Lentil/Parse/Syntaxes.hs     21  add langparsers che sia estensibile e leggibile a compilazione         [u:2] [feature:intermediate]-    40  multiline signature? [lint]-    41  tag at the beginning too? [design]+    42  multiline signature? [lint]+    43  tag at the beginning too? [design]   src/Main.hs     35  add doc to use less -r when piping hIsTerminalDevice stdout [doc]
lentil.cabal view
@@ -1,5 +1,5 @@ name:                lentil-version:             0.1.5.0+version:             0.1.6.0 synopsis:            frugal issue tracker description:         minumum effort, cohesive issue tracker based on                      ubiquitous @TODO@s and @FIXME@s conventions.
src/Lentil/Args.hs view
@@ -11,9 +11,11 @@  import Lentil.Types import Lentil.Query+import Lentil.Helpers  import Options.Applicative-import qualified Data.Char as C+import qualified Data.Char  as C+import qualified Data.Maybe as M   -----------@@ -27,6 +29,7 @@                            loFormat   :: Format,                            loFilters  :: [LFilter],                            loSort     :: [LSort],+                           loAlias    :: [Alias],                            loOutFile  :: Maybe FilePath }               deriving (Show) @@ -37,10 +40,11 @@  lOpts :: Parser LOptions lOpts = LOptions <$> inexcls <*> format <*> filters <*>-                     issort <*> outfile+                     issort <*> aliases <*> outfile     where inexcls = (,) <$> includes <*> many exclude           filters = many $ foldl1 (<|>) [tag, notag, path,                                          nopath, desc, nodesc]+          aliases = fmap M.catMaybes (many alias)   -------------@@ -72,6 +76,17 @@           forTup f      = (map C.toLower $ show f, f)  +alias :: Parser (Maybe Alias)+alias = option (str >>= parseAlias)+                   ( short 'a'       <>+                     metavar "ALIAS" <>+                     help ("extension alias (e.g.: -a cpp" ++ aliasSign +++                          "d)") )+    where+          parseAlias :: String -> ReadM (Maybe Alias)+          parseAlias s = return (aliasp s)++ outfile :: Parser (Maybe FilePath) outfile = optional $ strOption                     ( long "output"  <>@@ -160,4 +175,3 @@  rerr :: String -> String -> ReadM a rerr var msg = readerError $ msg ++ " \"" ++ var ++ "\""-
src/Lentil/File.hs view
@@ -42,8 +42,8 @@ --       repositories (like darcs). Explore different possibilities --       (conduit, new Filepath, unix program). [u:2] [duct] -findIssues :: [FilePath] -> [FilePath] -> IO [Issue]-findIssues is xs = mapM fc is >>= issueFinder . concat+findIssues :: [Alias] -> [FilePath] -> [FilePath] -> IO [Issue]+findIssues as is xs = mapM fc is >>= (issueFinder as) . concat     where           fc i = find always (findClause (xs' i)) i 
src/Lentil/Helpers.hs view
@@ -9,10 +9,35 @@  module Lentil.Helpers where +import Lentil.Types+ import qualified System.IO as I+import qualified Text.Parsec as P+import qualified Text.Parsec.String as PS +import Control.Applicative hiding ( (<|>), optional, many )+import Prelude -- 7.8 hack+ -- output errors perr :: String -> IO () perr cs  = I.hPutStrLn I.stderr cs+++-------------+-- PARSING --+-------------++-- like many1 for manyTill+manyTill1 :: PS.Parser a -> PS.Parser b -> PS.Parser [a]+manyTill1 p ed = (:) <$> p <*> P.manyTill p ed+++-- parse an extension alias "aa->bc" -> Just ("aa", "bc")+aliasp :: String -> Maybe Alias+aliasp s = either (const Nothing) Just (P.parse p "" s)+    where+          p = manyTill1 P.anyChar (P.string aliasSign) >>= \a ->+              P.many P.anyChar                         >>= \b ->+              return ('.':a, '.':b)  
src/Lentil/Parse/Run.hs view
@@ -24,11 +24,11 @@ import Prelude -- 7.8 hack  --- fixme: hGetContents: invalid argument (invalid byte sequence) [u:3]+-- fixme: hGetContents: invalid argument (invalid byte sequence) [u:3] [2016]  -- main function with wich to parse issues; errors on stderr-issueFinder :: [FilePath] -> IO [Issue]-issueFinder fps = fmap concat (mapM fileParser fps)+issueFinder :: [Alias] -> [FilePath] -> IO [Issue]+issueFinder as fps = fmap concat (mapM (fileParser as) fps)  -- todo a function String -> [Issue] (w/o IO) [debug] [refactor] @@ -37,8 +37,8 @@ -----------------  -- errors to stderr-fileParser :: FilePath -> IO [Issue]-fileParser fp = D.doesFileExist fp >>= \fb ->+fileParser :: [Alias] -> FilePath -> IO [Issue]+fileParser as fp = D.doesFileExist fp >>= \fb ->                  -- file exists                 if fb == False@@ -46,11 +46,12 @@                   else                  -- parser exists-                case langParser fp of+                case langParserAlias as fp of                   Nothing -> return [] -- no error just empy list                   Just p  -> readFile fp                >>=                              runParIO p fp              >>=                              parIssues fp . comms2Tuple+   -- generic parsing --
src/Lentil/Parse/Source.hs view
@@ -11,6 +11,7 @@ module Lentil.Parse.Source where  import Lentil.Types+import Lentil.Helpers  import Text.Parsec hiding (Line) @@ -38,15 +39,6 @@  data EscapeStyle = ClangLike | SQLLike                  deriving (Show, Eq)----------------------- ANCILLARIES ------------------------ like many1 for manyTill-manyTill1 :: ParSource a -> ParSource b -> ParSource [a]-manyTill1 p ed = (:) <$> p <*> manyTill p ed   --------------
src/Lentil/Parse/Syntaxes.hs view
@@ -11,6 +11,8 @@ module Lentil.Parse.Syntaxes where  import Lentil.Parse.Source+import Lentil.Types+ import Text.Parsec import Control.Applicative hiding (many) import Prelude@@ -18,9 +20,17 @@ import qualified System.FilePath as SF  +-- as langParser, with alias added+langParserAlias :: [Alias] -> String -> Maybe (ParSource [CommentString])+langParserAlias as fp = maybe (langParser fp) langParser (lookup ext as)+    where ext = SF.takeExtension fp++ -- TODO: add langparsers che sia estensibile e leggibile --       a compilazione [u:2] [feature:intermediate] +-- TODO: [u:3] extensions are case sensisive (no good)+ langParser :: String -> Maybe (ParSource [CommentString]) langParser fp | ext `elem` [".hs", ".lhs",                             ".hsc", ".chs" ]       = Just haskell@@ -40,7 +50,6 @@     where ext = SF.takeExtension fp  -- todo multiline signature? [lint]--- todo tag at the beginning too? [design] haskell, c, javascript, pascal, python, ruby :: ParSource [CommentString] perl, nix :: ParSource [CommentString] text :: ParSource [CommentString]
src/Lentil/Types.hs view
@@ -25,6 +25,12 @@ type Description = String type Row = Int +-- extension alias, will treat *.fst files as if they were *.snd+type Alias = (String, String)++aliasSign :: String+aliasSign = "%"+ -- output format data Format = TagPop | Pretty | Csv | Comp             deriving (Show, Eq, Enum, Bounded)
src/Main.hs view
@@ -28,14 +28,14 @@                                    short 'v'      <>                                    help "show version and copyright info" )     where-          versionCopy = "lentil - frugal issue tracker, version 0.1.5.0\n\+          versionCopy = "lentil - frugal issue tracker, version 0.1.6.0\n\                         \(C) 2015 Francesco Ariis - http://www.ariis.it\n\                         \released under the GNU General Public License v3\n" --- todo add doc to use less -r when piping hIsTerminalDevice stdout [doc]  runLentil :: LOptions -> IO ()-runLentil lo = uncurry findIssues (loInExcl lo) >>= \is -> -- grab issues+runLentil lo = uncurry (findIssues (loAlias lo))+                       (loInExcl lo) >>= \is -> -- grab issues                let fil = filterAnd (loFilters lo) is       -- filtered                    -- ord = chainSorts fil (loSort lo)        -- ordered                    -- todo leave sort out as now? [design]
test/Lentil/ArgsSpec.hs view
@@ -12,10 +12,10 @@ testOpt :: LOptions testOpt = LOptions (["alpha"], ["beta"]) Csv                    [filterFilepath "al", negFilter . filterTags $ "."]-                   [] (Just "foo.txt")+                   [] [("qq","s")] (Just "foo.txt")  ins :: [String]-ins  = words "alpha --format csv -x beta -p al -t ^ --output foo.txt"+ins  = words "alpha --format csv -x beta -p al -t ^ --a qq-s --output foo.txt"  -- out :: Maybe LOptions -- out = getParseResult .
test/Lentil/FileSpec.hs view
@@ -17,15 +17,15 @@    describe "findIssues" $ do     it "scans directories to find issues" $-      findIssues [bas ++ ""] [] >>= \fiss ->+      findIssues [] [bas ++ ""] [] >>= \fiss ->       length fiss `shouldBe` 5     it "allows to add specific folders" $-      findIssues [bas ++ ""] [] >>= \fiss ->-      findIssues [bas ++ "fold-a/", bas ++ "fold-b",-                  bas ++ "fold-c"] [] >>= \fiss2 ->+      findIssues [] [bas ++ ""] [] >>= \fiss ->+      findIssues [] [bas ++ "fold-a/", bas ++ "fold-b",+                     bas ++ "fold-c"] [] >>= \fiss2 ->       length fiss `shouldBe` length fiss2     it "accepts filenames instead of dirs, too" $-      findIssues [bas ++ "fold-a/foo1.hs"] [] >>= \fiss ->+      findIssues [] [bas ++ "fold-a/foo1.hs"] [] >>= \fiss ->       length fiss `shouldBe` 1  --     it "doesn't duplicate issues" $@@ -33,20 +33,20 @@ --       length fiss `shouldBe` 5      it "excludes some folders" $-      findIssues [bas ++ ""] [bas ++ "fold-c/"] >>= \fiss ->+      findIssues [] [bas ++ ""] [bas ++ "fold-c/"] >>= \fiss ->       length fiss `shouldBe` 2     it "excludes files" $-      findIssues [bas ++ ""] [bas ++ "fold-a/foo1.hs"] >>= \fiss ->+      findIssues [] [bas ++ ""] [bas ++ "fold-a/foo1.hs"] >>= \fiss ->       length fiss `shouldBe` 4     it "excludes subfolders" $-      findIssues [bas ++ "fold-c/"]+      findIssues [] [bas ++ "fold-c/"]                  [bas ++ "fold-c/sub-fold/"] >>= \fiss ->       length fiss `shouldBe` 1     it "doesn't crash on wrong file" $-      findIssues [bas ++ "zxczd"] [] >>= \fiss ->+      findIssues [] [bas ++ "zxczd"] [] >>= \fiss ->       length fiss `shouldBe` 0     it "does search outside $PWD" $-      findIssues [bas] []                    >>= \fiss  ->-      findIssues [bas ++ "../test-proj/"] [] >>= \fiss' ->+      findIssues [] [bas] []                    >>= \fiss  ->+      findIssues [] [bas ++ "../test-proj/"] [] >>= \fiss' ->       length fiss `shouldBe` length fiss' 
test/Lentil/Parse/RunSpec.hs view
@@ -28,7 +28,7 @@    describe "commentParser - specific" $ do     it "doesn't parse contiguous line/block as a single issue" $-        fileParser "test/test-files/specific/contiguous.c"+        fileParser [] "test/test-files/specific/contiguous.c"             `shouldReturn` [Issue "test/test-files/specific/contiguous.c" 1                                   (Just "issue1") []] @@ -38,40 +38,43 @@                 Issue fp 9 (Just "block2") [Tag "tog"]]   describe "commentParser - languages" $ do     it "parses a plain text source" $-        fileParser "test/test-files/lang-comm/text.txt"+        fileParser [] "test/test-files/lang-comm/text.txt"             `shouldReturn` spt "test/test-files/lang-comm/text.txt"     it "parses a haskell source" $-        fileParser "test/test-files/lang-comm/haskell.hs"+        fileParser [] "test/test-files/lang-comm/haskell.hs"             `shouldReturn` spt "test/test-files/lang-comm/haskell.hs"     it "parses a C source" $-        fileParser "test/test-files/lang-comm/clang.c"+        fileParser [] "test/test-files/lang-comm/clang.c"             `shouldReturn` spt "test/test-files/lang-comm/clang.c"     it "parses a Pascal source" $-        fileParser "test/test-files/lang-comm/pascal.pas"+        fileParser [] "test/test-files/lang-comm/pascal.pas"             `shouldReturn` spt "test/test-files/lang-comm/pascal.pas"     it "parses a javascript source" $-        fileParser "test/test-files/lang-comm/javascript.js"+        fileParser [] "test/test-files/lang-comm/javascript.js"             `shouldReturn` spt "test/test-files/lang-comm/javascript.js"     it "parses a python source" $-        fileParser "test/test-files/lang-comm/python.py"+        fileParser [] "test/test-files/lang-comm/python.py"             `shouldReturn` spt "test/test-files/lang-comm/python.py"     it "parses a ruby source" $-        fileParser "test/test-files/lang-comm/ruby.rb"+        fileParser [] "test/test-files/lang-comm/ruby.rb"             `shouldReturn` spt "test/test-files/lang-comm/ruby.rb"     it "parses a perl source" $-        fileParser "test/test-files/lang-comm/perl.pl"+        fileParser [] "test/test-files/lang-comm/perl.pl"             `shouldReturn` spt "test/test-files/lang-comm/perl.pl"     it "parses a shell script source" $-        fileParser "test/test-files/lang-comm/shell.sh"+        fileParser [] "test/test-files/lang-comm/shell.sh"             `shouldReturn` spt "test/test-files/lang-comm/shell.sh"     it "parses a Nix source" $-        fileParser "test/test-files/lang-comm/nix.nix"+        fileParser [] "test/test-files/lang-comm/nix.nix"             `shouldReturn` spt "test/test-files/lang-comm/nix.nix"+    it "parses a .xyz file as if it were a .c file" $+        fileParser [(".xyz", ".c")] "test/test-files/lang-comm/xyz.xyz"+            `shouldReturn` spt "test/test-files/lang-comm/xyz.xyz"    describe "issueFinder" $ do     it "reads a file (code or txt) for issues" $       let fp = "test/test-files/lang-comm/test.txt" in-      issueFinder [fp] >>= \i ->+      issueFinder [] [fp] >>= \i ->       i `shouldBe` [Issue fp 1 (Just "palla") [],                     Issue fp 3 (Just "beta")  [Tag "fixme"],                     Issue fp 4 (Just "gamma") [Tag "xxx"],
test/Lentil/Parse/SourceSpec.hs view
@@ -2,8 +2,6 @@  import Test.Hspec import Text.Parsec (runParser)-import Text.Parsec.Char-import Text.Parsec.Combinator  import Lentil.Types import Lentil.Parse.Source@@ -30,18 +28,6 @@  spec :: Spec spec = do--  describe "manyTill1" $ do-    it "behaves like manyTill on non-empty string" $-      sp (manyTill1 anyChar newline) "foo\n" `shouldBe`-      sp (manyTill anyChar newline) "foo\n"-    it "fails on empty string (while manyTill does not)" $-      (sp (manyTill1 anyChar newline) "\n",-       sp (manyTill  anyChar newline) "\n") `shouldBe` (Nothing,-                                                        Just "")-    it "has the same behaviour as manyTill on 1 char w/o end char" $-      sp (manyTill1 anyChar newline) "f" `shouldBe`-      sp (manyTill anyChar newline) "f"    describe "lineComment" $ do     it "parses a line comment" $