imp:close:--assert/--retain: no tag value; rename --assert's tag to assert:

This commit is contained in:
Simon Michael 2024-01-29 13:46:02 -10:00
parent d4ecdb3fea
commit e9dd01a7db

View File

@ -79,12 +79,11 @@ close copts@CliOpts{rawopts_=rawopts, reportspec_=rspec0} j = do
openacct = maybe closeacct T.pack $ maybestringopt "open-acct" rawopts openacct = maybe closeacct T.pack $ maybestringopt "open-acct" rawopts
-- For easy matching and exclusion, a recognisable tag is added to all generated transactions -- For easy matching and exclusion, a recognisable tag is added to all generated transactions
tagval = fromMaybe "" $ maybestringopt modeflag rawopts where modeflag = lowercase $ show mode_
comment = T.pack $ if comment = T.pack $ if
| mode_ == Assert -> "balances:" <> val | mode_ == Assert -> "assert:" <> tagval
| mode_ == Retain -> "retain:" <> val | mode_ == Retain -> "retain:" <> tagval
| otherwise -> "start:" <> val | otherwise -> "start:" <> if null tagval then inferredval else tagval
where
val = if null flagval then inferredval else flagval
where where
inferredval = newfilename inferredval = newfilename
where where
@ -98,10 +97,6 @@ close copts@CliOpts{rawopts_=rawopts, reportspec_=rspec0} j = do
newnum = show $ 1 + readDef err (reverse oldnum) -- PARTIAL: should not fail newnum = show $ 1 + readDef err (reverse oldnum) -- PARTIAL: should not fail
where err = error' $ "could not read " <> show oldnum <> " as a number in Hledger.Cli.Commands.Close.close" where err = error' $ "could not read " <> show oldnum <> " as a number in Hledger.Cli.Commands.Close.close"
flagval = fromMaybe "" $ maybestringopt modeflag rawopts
where
modeflag = lowercase $ show mode_
ropts = (_rsReportOpts rspec0){balanceaccum_=Historical, accountlistmode_=ALFlat} ropts = (_rsReportOpts rspec0){balanceaccum_=Historical, accountlistmode_=ALFlat}
rspec1 = setDefaultConversionOp NoConversionOp rspec0{_rsReportOpts=ropts} rspec1 = setDefaultConversionOp NoConversionOp rspec0{_rsReportOpts=ropts}