Expressions in ledger, query interface

35 views
Skip to first unread message

Martin Michlmayr

unread,
May 11, 2020, 10:30:18 PM5/11/20
to ledge...@googlegroups.com
I'm trying to understand something about the query interface.
Options like -l allow things like -l "amount > 100".

I can also specify the same without -l but then I need to
add "expr".

So I guess "amount > 100" is an expression in ledger lingo.

But then you can also specify queries on the command line
like /a/. I think this is a shorthand for "expr account =~ /a/".
Is that correct?

And @foo is a shorthand for the expression "payee =~ /foo/"

So the command line expects a "query", which can be a regex, @regex,
%regex. Or you can add an expression with "expr EXPRESSION".
Anything else that is allowed as a query? (And is "query" the
right word, or what are those things that are not expressions?)

And options like -l expect an expression.

Is this correct?

--
Martin Michlmayr
https://www.cyrius.com/

Martin Michlmayr

unread,
May 11, 2020, 10:47:33 PM5/11/20
to ledge...@googlegroups.com
As a follow-up, I don't think most of these expressions are properly
covered in the test suite.

If someone were to add such test cases, what would the naming
convention be? baseline/expr-<>.test?

John Wiegley

unread,
May 12, 2020, 12:35:19 AM5/12/20
to Martin Michlmayr, ledge...@googlegroups.com
>>>>> "MM" == Martin Michlmayr <t...@cyrius.com> writes:

MM> So the command line expects a "query", which can be a regex, @regex,
MM> %regex. Or you can add an expression with "expr EXPRESSION". Anything else
MM> that is allowed as a query? (And is "query" the right word, or what are
MM> those things that are not expressions?)

MM> And options like -l expect an expression.

This is correct. In fact, you can directly determine the differences using
these two debugging commands (which are probably undocumented?):

ledger expr a and b
ledger query a and b

John

Martin Michlmayr

unread,
May 12, 2020, 12:39:49 AM5/12/20
to ledge...@googlegroups.com
* John Wiegley <jwie...@gmail.com> [2020-05-11 21:34]:
> This is correct. In fact, you can directly determine the differences using
> these two debugging commands (which are probably undocumented?):

They are actually documented under PRE-COMMANDS in the man page.
Reply all
Reply to author
Forward
0 new messages