;import: with --dry-run the no txns case should be parseable too

This commit is contained in:
Simon Michael 2019-09-13 08:56:17 -07:00
parent f65fc47185
commit bf1e398ffd

View File

@ -40,8 +40,11 @@ importcmd opts@CliOpts{rawopts_=rawopts,inputopts_=iopts} j = do
Left e -> error' e Left e -> error' e
Right newj -> Right newj ->
case sortOn tdate $ jtxns newj of case sortOn tdate $ jtxns newj of
-- with --dry-run the output should be valid journal format, so messages have ; prepended
[] -> do [] -> 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 newts | dryrun -> do
printf "; would import %d new transactions from %s:\n\n" (length newts) inputstr printf "; would import %d new transactions from %s:\n\n" (length newts) inputstr
-- TODO how to force output here ? -- TODO how to force output here ?