2011-08-05 04:05:39 +04:00
|
|
|
# alias-related tests
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# simple alias directive
|
2015-05-14 22:50:32 +03:00
|
|
|
hledgerdev -f- accounts
|
|
|
|
<<<
|
|
|
|
alias checking = assets:bank:checking
|
|
|
|
1/1
|
|
|
|
(checking:a) 1
|
|
|
|
>>>
|
|
|
|
assets:bank:checking:a
|
|
|
|
>>>=0
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# simple alias matches whole account name components only
|
2015-05-14 22:50:32 +03:00
|
|
|
hledgerdev -f- accounts
|
|
|
|
<<<
|
|
|
|
alias a:b = A:B
|
|
|
|
1/1
|
|
|
|
(a:b:c) 1 ; should match this
|
|
|
|
1/1
|
|
|
|
(a:bb:d) 1 ; should not match this
|
|
|
|
>>>
|
|
|
|
A:B:c
|
|
|
|
a:bb:d
|
|
|
|
>>>=0
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# regex alias directive
|
2015-05-14 22:50:32 +03:00
|
|
|
hledgerdev -f- accounts
|
|
|
|
<<<
|
|
|
|
alias /^(.+):bank:([^:]+):?(.*)/ = \1:\2 \3
|
|
|
|
1/1
|
|
|
|
(assets:bank:B:checking:a) 1
|
|
|
|
>>>
|
|
|
|
assets:B checking:a
|
|
|
|
>>>=0
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# regex alias pattern is a case-insensitive regular expression
|
2015-05-14 22:50:32 +03:00
|
|
|
# matching anywhere in the account name. All matching aliases are
|
|
|
|
# applied to an account name in turn, most recently seen first. The
|
|
|
|
# replacement can replace multiple matches within the account name.
|
|
|
|
# The replacement pattern supports numeric backreferences.
|
2014-10-25 02:05:10 +04:00
|
|
|
#
|
|
|
|
hledgerdev -f- print
|
2011-08-05 04:05:39 +04:00
|
|
|
<<<
|
2015-05-14 22:50:32 +03:00
|
|
|
alias /a/ = b
|
2014-10-25 02:05:10 +04:00
|
|
|
|
2011-08-05 04:05:39 +04:00
|
|
|
2011/01/01
|
2014-10-25 02:05:10 +04:00
|
|
|
A a 1
|
|
|
|
a a 2
|
|
|
|
c
|
|
|
|
|
2015-05-14 22:50:32 +03:00
|
|
|
alias /A (.)/=\1
|
2014-10-25 02:05:10 +04:00
|
|
|
|
|
|
|
2011/01/01
|
|
|
|
A a 1
|
|
|
|
a a 2
|
2011-08-05 04:05:39 +04:00
|
|
|
c
|
|
|
|
|
|
|
|
>>>
|
|
|
|
2011/01/01
|
2014-10-25 02:05:10 +04:00
|
|
|
b b 1
|
|
|
|
b b 2
|
|
|
|
c -3
|
|
|
|
|
|
|
|
2011/01/01
|
2014-10-29 18:20:27 +03:00
|
|
|
b 1
|
|
|
|
b 2
|
2014-10-29 17:46:49 +03:00
|
|
|
c -3
|
2011-08-05 04:05:39 +04:00
|
|
|
|
|
|
|
>>>=0
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# --alias command-line options are applied in the order written.
|
2015-05-14 22:50:32 +03:00
|
|
|
# Spaces are allowed if quoted.
|
2014-10-25 02:05:10 +04:00
|
|
|
#
|
2015-05-14 22:50:32 +03:00
|
|
|
hledgerdev -f- print --alias '/A (.)/=a' --alias /a/=b
|
2011-08-05 04:05:39 +04:00
|
|
|
<<<
|
|
|
|
2011/01/01
|
2014-10-25 02:05:10 +04:00
|
|
|
a a 1
|
|
|
|
A a 2
|
|
|
|
c
|
2011-08-05 04:05:39 +04:00
|
|
|
|
|
|
|
>>>
|
|
|
|
2011/01/01
|
2014-10-29 18:20:27 +03:00
|
|
|
b 1
|
|
|
|
b 2
|
2014-10-25 02:05:10 +04:00
|
|
|
c -3
|
2011-08-05 04:05:39 +04:00
|
|
|
|
|
|
|
>>>=0
|
|
|
|
|
2015-05-28 20:18:54 +03:00
|
|
|
# alias options are applied after alias directives.
|
2014-10-25 02:05:10 +04:00
|
|
|
#
|
2015-05-14 22:50:32 +03:00
|
|
|
hledgerdev -f- print --alias /a/=A --alias /B/=C --alias /B/=D --alias /C/=D
|
2011-08-05 04:05:39 +04:00
|
|
|
<<<
|
2015-05-14 22:50:32 +03:00
|
|
|
alias /^a/=B
|
|
|
|
alias /^a/=E
|
2014-10-25 02:05:10 +04:00
|
|
|
alias E=F
|
2011-08-05 04:05:39 +04:00
|
|
|
|
|
|
|
2011/01/01
|
|
|
|
[a:x] 1
|
|
|
|
[x:a:x]
|
|
|
|
|
|
|
|
>>>
|
|
|
|
2011/01/01
|
2014-10-25 02:05:10 +04:00
|
|
|
[E:x] 1
|
|
|
|
[x:A:x] -1
|
2011-08-05 04:05:39 +04:00
|
|
|
|
|
|
|
>>>2
|
|
|
|
>>>=0
|