queryFromOptsOnly for when args aren't query terms
This commit is contained in:
parent
204af487a5
commit
73c09f91d7
@ -22,6 +22,7 @@ module Hledger.Reports (
|
||||
whichDateFromOpts,
|
||||
journalSelectingAmountFromOpts,
|
||||
queryFromOpts,
|
||||
queryFromOptsOnly,
|
||||
queryOptsFromOpts,
|
||||
reportSpans,
|
||||
-- * Entries report
|
||||
@ -223,6 +224,17 @@ queryFromOpts d opts@ReportOpts{..} = simplifyQuery $ And $ [flagsq, argsq]
|
||||
++ (maybe [] ((:[]) . Depth) depth_)
|
||||
argsq = fst $ parseQuery d query_
|
||||
|
||||
-- | Convert report options to a query, ignoring any non-flag command line arguments.
|
||||
queryFromOptsOnly :: Day -> ReportOpts -> Query
|
||||
queryFromOptsOnly d opts@ReportOpts{..} = simplifyQuery flagsq
|
||||
where
|
||||
flagsq = And $
|
||||
[(if date2_ then Date2 else Date) $ dateSpanFromOpts d opts]
|
||||
++ (if real_ then [Real True] else [])
|
||||
++ (if empty_ then [Empty True] else []) -- ?
|
||||
++ (maybe [] ((:[]) . Status) (clearedValueFromOpts opts))
|
||||
++ (maybe [] ((:[]) . Depth) depth_)
|
||||
|
||||
tests_queryFromOpts = [
|
||||
"queryFromOpts" ~: do
|
||||
assertEqual "" Any (queryFromOpts nulldate defreportopts)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user