From 26ae1fc40d0248428cf19e394a5d71a65906bc41 Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Thu, 8 Dec 2022 15:44:39 +0100 Subject: [PATCH] Change flag semantics: match prefix by default New variants summarize-any, skip-any, yield-any to match anywhere in the input lines --- src-hxbrief/Main.hs | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src-hxbrief/Main.hs b/src-hxbrief/Main.hs index 59a4dfc..ee34f7d 100644 --- a/src-hxbrief/Main.hs +++ b/src-hxbrief/Main.hs @@ -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