From bf1e398ffd28cd07ff4e1674e837b69807442fde Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 13 Sep 2019 08:56:17 -0700 Subject: [PATCH] ;import: with --dry-run the no txns case should be parseable too --- hledger/Hledger/Cli/Commands/Import.hs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hledger/Hledger/Cli/Commands/Import.hs b/hledger/Hledger/Cli/Commands/Import.hs index 6554c14b7..a30a7d8a3 100755 --- a/hledger/Hledger/Cli/Commands/Import.hs +++ b/hledger/Hledger/Cli/Commands/Import.hs @@ -40,8 +40,11 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do Left e -> error' e Right newj -> case sortOn tdate $ jtxns newj of + -- with --dry-run the output should be valid journal format, so messages have ; prepended [] -> do - printf "no new transactions found in %s.\n\n" inputstr + -- in this case, we vary the output depending on --dry-run, which is a bit awkward + let semicolon = if dryrun then "; " else "" :: String + printf "%sno new transactions found in %s.\n\n" semicolon inputstr newts | dryrun -> do printf "; would import %d new transactions from %s:\n\n" (length newts) inputstr -- TODO how to force output here ?