cgrep 9.2.1 → 9.2.2
raw patch · 4 files changed
+17/−10 lines, 4 files
Files
- README.md +3/−3
- cgrep.cabal +1/−1
- src/CmdOptions.hs +1/−1
- src/Main.hs +12/−5
README.md view
@@ -411,10 +411,10 @@ ```bash # Search for "config" only in production code, skipping all tests-cgrep -T False "config" -r src/+cgrep --no-tests "config" -r src/ # Search for mock usage only in test files-cgrep -T True "mock" -r .+cgrep --tests-only "mock" -r . ``` ---@@ -471,7 +471,7 @@ 4. **Use test filtering** to focus on production code: ```bash- cgrep -T False "pattern" -r . # Exclude all test code+ cgrep --no-tests "pattern" -r . # Exclude all test code ``` 5. **Adjust thread count** for optimal performance on your system:
cgrep.cabal view
@@ -1,7 +1,7 @@ cabal-version: 2.2 name: cgrep description: Cgrep: a context-aware grep for source codes-version: 9.2.1+version: 9.2.2 synopsis: Command line tool homepage: http://awgn.github.io/cgrep/ license: GPL-2.0-or-later
src/CmdOptions.hs view
@@ -52,7 +52,7 @@ import Options.Applicative (hidden) import Data.Version (showVersion) --- Parser per le opzioni+-- Parser options options :: Parser Options options = Options <$> optional(strOption
src/Main.hs view
@@ -28,8 +28,9 @@ import GHC.IO.Handle (hIsTerminalDevice) import Options.Applicative (execParser)+import Data.Maybe (isJust) import System.Environment (withArgs)-import System.Exit (exitSuccess)+import System.Exit (die, exitSuccess) import System.IO (stdin, stdout) import CGrep.Common (trimT)@@ -83,10 +84,7 @@ when show_palette $ dumpPalette >> exitSuccess - -- check whether the pattern list is empty, display help message if it's the case- when (null others && isTermIn && null file) $- withArgs ["--help"] $- void (execParser parserInfo)+ validateOptions opt isTermIn let others' = T.pack <$> others @@ -123,6 +121,15 @@ readPatternsFromFile f | OS.null f = return [] | otherwise = map trimT . T.lines <$> TIO.readFile (OS.toFilePath f)++validateOptions :: Options -> Bool -> IO ()+validateOptions Options{..} isTermIn = do+ when (null others && isTermIn && null file) $+ withArgs ["--help"] $+ void (execParser parserInfo)+ + when (isJust tests && not semantic) $+ die "cgrep: the options --tests-only and --no-tests require semantic search (-S or --semantic)." splitPatternsAndFiles :: [T.Text] -> ([T.Text], [OsPath]) splitPatternsAndFiles [] = ([], [])