Beanquery "expand" when calling from command line

24 views
Skip to first unread message

Eric Altendorf

unread,
Aug 2, 2023, 1:34:50 PM8/2/23
to bean...@googlegroups.com
It doesn't appear that bean-query allows you to issue a `set` followed by a query in a single line:

beanquery> set expand true; select balance where year=2018;
Invalid number of arguments.

When interactive, of course this is not important.  However, being able to do this would be useful for generating from the command line reports with expand=true.

I looked into the code and it appears this happens because the `set` command is handled by the interactive shell and is not part of the ebnf grammar which is where semicolon-delimited statement sequences are defined.  The structure of the interactive shell also seems to be fairly designed around interactivity, and handling statement sequences there looks awkward.

Any other workarounds?

eric

Daniele Nicolodi

unread,
Aug 2, 2023, 2:41:01 PM8/2/23
to bean...@googlegroups.com
The beanquery interpreter does not handle multiple commands separated by
semicolons, it does not matter if these are BQL statements ore
meta-commands implemented by the shell. It is a known limitation but I
haven't had occasion to work on it yet.

The idea is that it should be possible to apply all settings that can be
applied interactively with 'set' also via command line arguments. But
this hasn't been implemented yet either.

The only work-around for not-interactive queries is to put the 'set'
meta-commands in the shell init file at ~/.config/beanquery/init
This is a thing that I've just implemented, thus you need a fairly
recent installation.

Cheers,
Dan

Eric Altendorf

unread,
Aug 2, 2023, 3:04:37 PM8/2/23
to bean...@googlegroups.com
On Wed, Aug 2, 2023 at 11:41 AM Daniele Nicolodi <dan...@grinta.net> wrote:
On 02/08/23 19:34, Eric Altendorf wrote:
> It doesn't appear that bean-query allows you to issue a `set` followed
> by a query in a single line:
>
> beanquery> set expand true; select balance where year=2018;
> Invalid number of arguments.
>
> When interactive, of course this is not important.  However, being able
> to do this would be useful for generating from the command line reports
> with expand=true.
>
> I looked into the code and it appears this happens because the `set`
> command is handled by the interactive shell and is not part of the ebnf
> grammar which is where semicolon-delimited statement sequences are
> defined.  The structure of the interactive shell also seems to be fairly
> designed around interactivity, and handling statement sequences there
> looks awkward.
>
> Any other workarounds?

The beanquery interpreter does not handle multiple commands separated by
semicolons, it does not matter if these are BQL statements ore
meta-commands implemented by the shell.  It is a known limitation but I
haven't had occasion to work on it yet.

The idea is that it should be possible to apply all settings that can be
applied interactively with 'set' also via command line arguments.  But
this hasn't been implemented yet either.

That makes sense.
 

The only work-around for not-interactive queries is to put the 'set'
meta-commands in the shell init file at ~/.config/beanquery/init
This is a thing that I've just implemented, thus you need a fairly
recent installation.

This will work for me, thank you!
 

Cheers,
Dan

--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/ec80db1e-818c-70b3-b8b0-6ce9c29ce254%40grinta.net.
Reply all
Reply to author
Forward
0 new messages