imp: print: a failed --match now returns a non-zero exit code

This commit is contained in:
Simon Michael 2022-11-09 08:56:48 -10:00
parent e8302b0964
commit 7997007dcf
2 changed files with 4 additions and 2 deletions

View File

@ -28,6 +28,7 @@ import Hledger
import Hledger.Read.CsvReader (CSV, printCSV) import Hledger.Read.CsvReader (CSV, printCSV)
import Hledger.Cli.CliOptions import Hledger.Cli.CliOptions
import Hledger.Cli.Utils import Hledger.Cli.Utils
import System.Exit (exitFailure)
printmode = hledgerCommandMode printmode = hledgerCommandMode
@ -203,5 +204,5 @@ postingToCSV p =
printMatch :: CliOpts -> Journal -> Text -> IO () printMatch :: CliOpts -> Journal -> Text -> IO ()
printMatch opts j desc = do printMatch opts j desc = do
case journalSimilarTransaction opts j desc of case journalSimilarTransaction opts j desc of
Nothing -> putStrLn "no matches found." Nothing -> putStrLn "no matches found." >> exitFailure
Just t -> T.putStr $ showTransaction t Just t -> T.putStr $ showTransaction t

View File

@ -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 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 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. 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. This uses the same deduplication system as the [`import`](#import) command.