From 7997007dcf1c8f78bf0000341089f5dbedee85d0 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Wed, 9 Nov 2022 08:56:48 -1000 Subject: [PATCH] imp: print: a failed --match now returns a non-zero exit code --- hledger/Hledger/Cli/Commands/Print.hs | 3 ++- hledger/Hledger/Cli/Commands/Print.md | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hledger/Hledger/Cli/Commands/Print.hs b/hledger/Hledger/Cli/Commands/Print.hs index e39c6dcb3..8f4e274b1 100644 --- a/hledger/Hledger/Cli/Commands/Print.hs +++ b/hledger/Hledger/Cli/Commands/Print.hs @@ -28,6 +28,7 @@ import Hledger import Hledger.Read.CsvReader (CSV, printCSV) import Hledger.Cli.CliOptions import Hledger.Cli.Utils +import System.Exit (exitFailure) printmode = hledgerCommandMode @@ -203,5 +204,5 @@ postingToCSV p = printMatch :: CliOpts -> Journal -> Text -> IO () printMatch opts j desc = do case journalSimilarTransaction opts j desc of - Nothing -> putStrLn "no matches found." + Nothing -> putStrLn "no matches found." >> exitFailure Just t -> T.putStr $ showTransaction t diff --git a/hledger/Hledger/Cli/Commands/Print.md b/hledger/Hledger/Cli/Commands/Print.md index f969e01ec..ebe7f30ea 100644 --- a/hledger/Hledger/Cli/Commands/Print.md +++ b/hledger/Hledger/Cli/Commands/Print.md @@ -78,7 +78,8 @@ are converted to cost using that price. This can be used for troubleshooting. With `-m`/`--match` and a STR argument, print will show at most one transaction: the one one whose description is most similar to STR, and is most recent. STR should contain at -least two characters. If there is no similar-enough match, no transaction will be shown. +least two characters. If there is no similar-enough match, no transaction will be shown +(and command's exit code will be non-zero). With `--new`, hledger prints only transactions it has not seen on a previous run. This uses the same deduplication system as the [`import`](#import) command.