lib: save the current date in ReportOpts
We need this for choosing a valuation date, otherwise, report functions would have to be in IO or we'd have to pass in yet another argument. It's optional because it's useful to be able to create report opts purely (I think ?) This is not ideal but maybe not a problem.
This commit is contained in:
parent
d04a5a03f0
commit
ef9c4a29c4
@ -77,12 +77,15 @@ instance Default AccountListMode where def = ALDefault
|
|||||||
-- or query arguments, but not all. Some are used only by certain
|
-- or query arguments, but not all. Some are used only by certain
|
||||||
-- commands, as noted below.
|
-- commands, as noted below.
|
||||||
data ReportOpts = ReportOpts {
|
data ReportOpts = ReportOpts {
|
||||||
period_ :: Period
|
today_ :: Maybe Day -- ^ The current date. A late addition to ReportOpts.
|
||||||
|
-- Optional, but when set it may affect some reports:
|
||||||
|
-- Reports use it when picking a -V valuation date.
|
||||||
|
,period_ :: Period
|
||||||
,interval_ :: Interval
|
,interval_ :: Interval
|
||||||
,statuses_ :: [Status] -- ^ Zero, one, or two statuses to be matched
|
,statuses_ :: [Status] -- ^ Zero, one, or two statuses to be matched
|
||||||
,cost_ :: Bool
|
,cost_ :: Bool
|
||||||
,depth_ :: Maybe Int
|
,depth_ :: Maybe Int
|
||||||
,display_ :: Maybe DisplayExp
|
,display_ :: Maybe DisplayExp -- XXX unused ?
|
||||||
,date2_ :: Bool
|
,date2_ :: Bool
|
||||||
,empty_ :: Bool
|
,empty_ :: Bool
|
||||||
,no_elide_ :: Bool
|
,no_elide_ :: Bool
|
||||||
@ -146,6 +149,7 @@ defreportopts = ReportOpts
|
|||||||
def
|
def
|
||||||
def
|
def
|
||||||
def
|
def
|
||||||
|
def
|
||||||
|
|
||||||
rawOptsToReportOpts :: RawOpts -> IO ReportOpts
|
rawOptsToReportOpts :: RawOpts -> IO ReportOpts
|
||||||
rawOptsToReportOpts rawopts = checkReportOpts <$> do
|
rawOptsToReportOpts rawopts = checkReportOpts <$> do
|
||||||
@ -153,7 +157,8 @@ rawOptsToReportOpts rawopts = checkReportOpts <$> do
|
|||||||
d <- getCurrentDay
|
d <- getCurrentDay
|
||||||
color <- hSupportsANSI stdout
|
color <- hSupportsANSI stdout
|
||||||
return defreportopts{
|
return defreportopts{
|
||||||
period_ = periodFromRawOpts d rawopts'
|
today_ = Just d
|
||||||
|
,period_ = periodFromRawOpts d rawopts'
|
||||||
,interval_ = intervalFromRawOpts rawopts'
|
,interval_ = intervalFromRawOpts rawopts'
|
||||||
,statuses_ = statusesFromRawOpts rawopts'
|
,statuses_ = statusesFromRawOpts rawopts'
|
||||||
,cost_ = boolopt "cost" rawopts'
|
,cost_ = boolopt "cost" rawopts'
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user