lib: multiple status: query terms are OR'd (#564)
Like desc: and acct:. I think this is more intuitive and useful, so now eg "status: status:!" works (equivalent to -UP or "not:status:*").
This commit is contained in:
parent
7fc921db86
commit
5d28120f6d
@ -155,15 +155,17 @@ data QueryOpt = QueryOptInAcctOnly AccountName -- ^ show an account register fo
|
||||
-- Multiple terms are combined as follows:
|
||||
-- 1. multiple account patterns are OR'd together
|
||||
-- 2. multiple description patterns are OR'd together
|
||||
-- 3. then all terms are AND'd together
|
||||
-- 3. multiple status patterns are OR'd together
|
||||
-- 4. then all terms are AND'd together
|
||||
parseQuery :: Day -> T.Text -> (Query,[QueryOpt])
|
||||
parseQuery d s = (q, opts)
|
||||
where
|
||||
terms = words'' prefixes s
|
||||
(pats, opts) = partitionEithers $ map (parseQueryTerm d) terms
|
||||
(descpats, pats') = partition queryIsDesc pats
|
||||
(acctpats, otherpats) = partition queryIsAcct pats'
|
||||
q = simplifyQuery $ And $ [Or acctpats, Or descpats] ++ otherpats
|
||||
(acctpats, pats'') = partition queryIsAcct pats'
|
||||
(statuspats, otherpats) = partition queryIsStatus pats''
|
||||
q = simplifyQuery $ And $ [Or acctpats, Or descpats, Or statuspats] ++ otherpats
|
||||
|
||||
tests_parseQuery = [
|
||||
"parseQuery" ~: do
|
||||
|
||||
@ -100,3 +100,16 @@ hledger -fstatus.journal print status:
|
||||
|
||||
>>>=0
|
||||
|
||||
# 11. multiple status: queries are OR'd
|
||||
hledger -fstatus.journal print status: status:!
|
||||
>>>
|
||||
2017/01/01 uncleared
|
||||
(a) 1
|
||||
(b) 1
|
||||
|
||||
2017/01/02 ! pending
|
||||
(a) 1
|
||||
! (b) 1
|
||||
|
||||
>>>= 0
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user