Various Tools for interacting with Beancount commands and files in the Perl language
d6914c481c
After some efforts to make this current incarnation of the daemon work for situations with excessively long output, I discovered two problems. First, bean-query seems to always use a pager in interactive mode, and it seems impossible to dissuade bean-query from this behavior without an upstream change to Beancount. As such, my first effort was to force the pager to be `/usr/bin/cat`, which I thought would be sufficient to solve the problem entirely. After that change coupled with much debugging with IPC::Run, I found that detecting the beancount> prompt using a regular expression of /^\s*beancount\s*\>\s*/m, or similar efforts with simply /\s*beancount\s*/ or other versions like /\s*beancount\s*\>\s*$/ms /\s*beancount\s*\>\s*$/s, simply would not detect the end of the string, so the process hung on this line in the main loop: pump $runningBeanQuery until $rbcOut =~ /^\s*beancount\s*\>\s*/m; Ironically, when there is *not* copious output, that line worked just fine. It was baffling. I switched to Expect, and found the exact same behavior with: $runningBeanQuery->expect(undef, -re => '^\s*beancount\s*\>\s*') with that line, it works fine in the StartRunningBeanQuery() subroutine, but when used in the main loop, Expect never finds that string. Again, I tried it with various regexes as specified above to no avail. *However*, merely changing the line to: $runningBeanQuery->expect(undef, 'beancount>') (i.e., not using the regex feature in the Expect library), fixed the problem entirely. My working theory is some complex interaction bug between the IO::Pty module, regular expression matching, and output timing (since this problem only shows up when there is copious output). I think in particular the fact that bean-query creates a subprocess for the `PAGER` command in the pty when the output is copious is somehow related to the problem. Regardless, this solution now works in all the cases where I'm using the daemon, so I'm not investigating further. |
||
---|---|---|
AGPL-3.0.txt | ||
bean-query-daemon-lib.pl | ||
bean-query-goofy-daemon.plx | ||
COPYRIGHT | ||
LICENSE | ||
README.md |
Beancount Tools Written in Perl
These are various tools written in Perl to interact with Beancount project.
bean-query-goofy-daemon.plx
This daemon uses Perl's IPC::Shareable
library to take queries as a daemon for Beancount's bean-query
. Note that this daemon is not particularly secure, as it has the same security flaws inherent in IPC::Shareable
and use of named pipes (as it uses mkfifo
from Perl's POSIX
library underneath.
bean-query-daemon-lib.pl
This file defines three functions to use in client scripts that want to talk to bean-query-goofy-daemon.plx
.
It's not an actual Perl library; just use require
in Perl to load it.
[comment]: Local variables: [comment]: mode: markdown [comment]: eval: (visual-line-mode t) [comment]: eval: (auto-fill-mode -1) [comment]: End: