imp:close:--assert/--retain: no tag value; rename --assert's tag to assert:
This commit is contained in:
parent
d4ecdb3fea
commit
e9dd01a7db
@ -79,28 +79,23 @@ 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
|
where
|
||||||
val = if null flagval then inferredval else flagval
|
inferredval = newfilename
|
||||||
where
|
where
|
||||||
inferredval = newfilename
|
oldfilename = takeFileName $ journalFilePath j
|
||||||
where
|
(nonnum, rest) = break isDigit $ reverse oldfilename
|
||||||
oldfilename = takeFileName $ journalFilePath j
|
(oldnum, rest2) = span isDigit rest
|
||||||
(nonnum, rest) = break isDigit $ reverse oldfilename
|
newfilename = case oldnum of
|
||||||
(oldnum, rest2) = span isDigit rest
|
[] -> ""
|
||||||
newfilename = case oldnum of
|
_ -> reverse rest2 <> newnum <> reverse nonnum
|
||||||
[] -> ""
|
where
|
||||||
_ -> reverse rest2 <> newnum <> reverse nonnum
|
newnum = show $ 1 + readDef err (reverse oldnum) -- PARTIAL: should not fail
|
||||||
where
|
where err = error' $ "could not read " <> show oldnum <> " as a number in Hledger.Cli.Commands.Close.close"
|
||||||
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"
|
|
||||||
|
|
||||||
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}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user