Change flag semantics: match prefix by default

New variants summarize-any, skip-any, yield-any to match
anywhere in the input lines
master
Lennart Spitzner 2022-12-08 15:44:39 +01:00
parent d8fa897a70
commit 26ae1fc40d
1 changed files with 32 additions and 9 deletions

View File

@ -473,12 +473,32 @@ main = B.mainFromCmdParser $ do
conflateStdout <- B.addSimpleBoolFlag "" ["conflate-out"] mempty
conflateStderr <- B.addSimpleBoolFlag "" ["conflate-err"] mempty
conflateBoth <- B.addSimpleBoolFlag "" ["conflate"] mempty
summarize <- B.addFlagStringParams "s" ["summarize"] "PATTERN" mempty
skip <- B.addFlagStringParams "x" ["skip"] "PATTERN" mempty
label <- B.addFlagStringParams "" ["label"] "STRING" mempty
yield <- B.addFlagStringParams "y" ["yield"] "PATTERN" mempty
omitSummary <- B.addSimpleBoolFlag "" ["omit-summary"] mempty
tee <- B.addFlagStringParams
summarize <- B.addFlagStringParams
"s"
["summarize"]
"REGEX"
(B.flagHelpStr "bundle lines starting with this pattern into one line")
summarizeFull <- B.addFlagStringParams
""
["summarize-any"]
"REGEX"
(B.flagHelpStr "bundle lines containing this pattern into one line")
skip <- B.addFlagStringParams
"x"
["skip"]
"REGEX"
(B.flagHelpStr "drop lines starting with this pattern, similar to `grep -v`"
)
skipFull <- B.addFlagStringParams
""
["skip-any"]
"REGEX"
(B.flagHelpStr "drop lines containing this pattern, similar to `grep -v`")
label <- B.addFlagStringParams "" ["label"] "STRING" mempty
yield <- B.addFlagStringParams "y" ["yield"] "REGEX" mempty
yieldFull <- B.addFlagStringParams "" ["yield-any"] "REGEX" mempty
omitSummary <- B.addSimpleBoolFlag "" ["omit-summary"] mempty
tee <- B.addFlagStringParams
""
["tee"]
"BASENAMEBASEPATH"
@ -575,9 +595,12 @@ main = B.mainFromCmdParser $ do
compiled_summarize <-
sequence
$ join
$ [ yield <&> compiler JoinYield
, summarize <&> compiler JoinSpecific
, skip <&> compiler JoinAll
$ [ yield <&> compiler JoinYield . (\x -> "^(" ++ x ++ ")")
, yieldFull <&> compiler JoinYield
, summarize <&> compiler JoinSpecific . (\x -> "^(" ++ x ++ ")")
, summarizeFull <&> compiler JoinSpecific
, skip <&> compiler JoinAll . (\x -> "^(" ++ x ++ ")")
, skipFull <&> compiler JoinAll
]
(lastLine, ecMay) <- displayConsoleRegions $ do
initialState <- do