Glue for IPC now can be overridden via BeancountQueryInitialize()
Allow a single optional parameter to BeancountQueryInitialize() that overrides the default glue used for the IPC::Sharable glue.
This commit is contained in:
parent
f43e0000d1
commit
a5967d4cf9
2 changed files with 13 additions and 9 deletions
|
@ -11,7 +11,9 @@ our %BEANCOUNT_QUERY;
|
||||||
|
|
||||||
my $IPC_GLUE = 'BeAn';
|
my $IPC_GLUE = 'BeAn';
|
||||||
|
|
||||||
sub BeancountQueryInitialize {
|
sub BeancountQueryInitialize (;$) {
|
||||||
|
$IPC_GLUE = $_[0] if (defined $_[0]);
|
||||||
|
die "Glue must be exactly four characters" unless defined $IPC_GLUE and length($IPC_GLUE) == 4;
|
||||||
my %options = (create => 0, exclusive => 0, mode => 0600, destroy => 0);
|
my %options = (create => 0, exclusive => 0, mode => 0600, destroy => 0);
|
||||||
tie %BEANCOUNT_QUERY, 'IPC::Shareable', $IPC_GLUE, { %options } or
|
tie %BEANCOUNT_QUERY, 'IPC::Shareable', $IPC_GLUE, { %options } or
|
||||||
die "BEANCOUNT_QUERY: tie failed: is the goffy beancount server running?\n";
|
die "BEANCOUNT_QUERY: tie failed: is the goffy beancount server running?\n";
|
||||||
|
|
|
@ -28,13 +28,13 @@ $ENV{PAGER} = "/usr/bin/cat";
|
||||||
|
|
||||||
my $BEANCOUNT_QUERY_CMD = "/usr/bin/bean-query";
|
my $BEANCOUNT_QUERY_CMD = "/usr/bin/bean-query";
|
||||||
|
|
||||||
my($VERBOSE, $BEANCOUNT_DIR, $LOAD_FILE, $BRANCH_NAME, $FIFO_DIR) = (0, undef, undef, undef, undef);
|
my($VERBOSE, $BEANCOUNT_DIR, $LOAD_FILE, $BRANCH_NAME, $FIFO_DIR, $CLEAR_FILES, $GLUE) = (0, undef, undef, undef, undef, 1, 'BeAn');
|
||||||
|
|
||||||
GetOptions("verbose=i" => \$VERBOSE, "beancountDir=s" => \$BEANCOUNT_DIR,
|
GetOptions("verbose=i" => \$VERBOSE, "beancountDir=s" => \$BEANCOUNT_DIR, 'glue=s' => \$GLUE, 'clearFiles!', \$CLEAR_FILES,
|
||||||
"loadFile=s" => \$LOAD_FILE, "branchName=s" => \$BRANCH_NAME, 'fifoDir=s' => \$FIFO_DIR);
|
"loadFile=s" => \$LOAD_FILE, "branchName=s" => \$BRANCH_NAME, 'fifoDir=s' => \$FIFO_DIR);
|
||||||
|
|
||||||
sub UsageAndExit($) {
|
sub UsageAndExit($) {
|
||||||
print STDERR "usage: $0 --loadFile=/path/to/file.beancount --beancountDir=/path/to/beancountdir --fifoDir=/path/to/directory/for/fifos [ --branchName=BRANCH_NAME --verbose=N ]\n";
|
print STDERR "usage: $0 --loadFile=/path/to/file.beancount --beancountDir=/path/to/beancountdir --fifoDir=/path/to/directory/for/fifos [ --glue=FOUR_CHAR_STRING --branchName=BRANCH_NAME --verbose=N ]\n";
|
||||||
print STDERR "\n $_[0]\n";
|
print STDERR "\n $_[0]\n";
|
||||||
exit 2;
|
exit 2;
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,9 @@ chdir $BEANCOUNT_DIR;
|
||||||
UsageAndExit("/path/to/file.beancount must a relative path to a file that exists in $BEANCOUNT_DIR")
|
UsageAndExit("/path/to/file.beancount must a relative path to a file that exists in $BEANCOUNT_DIR")
|
||||||
unless (defined $LOAD_FILE and -r $LOAD_FILE);
|
unless (defined $LOAD_FILE and -r $LOAD_FILE);
|
||||||
|
|
||||||
|
UsageAndExit("glue must be at exactly four characters")
|
||||||
|
unless (defined $GLUE and length($GLUE) == 4);
|
||||||
|
|
||||||
my($tempRepository, $tempRepositoryDirectory);
|
my($tempRepository, $tempRepositoryDirectory);
|
||||||
|
|
||||||
sub CleanupEvertything {
|
sub CleanupEvertything {
|
||||||
|
@ -103,7 +106,6 @@ sub CheckUpstreamAndPull {
|
||||||
"so give up entirely on trying to make this work.");
|
"so give up entirely on trying to make this work.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
my $glue = 'BeAn';
|
|
||||||
my %options = (
|
my %options = (
|
||||||
create => 'yes',
|
create => 'yes',
|
||||||
exclusive => 0,
|
exclusive => 0,
|
||||||
|
@ -111,13 +113,13 @@ my %options = (
|
||||||
destroy => 'yes',
|
destroy => 'yes',
|
||||||
);
|
);
|
||||||
my %query;
|
my %query;
|
||||||
tie %query, 'IPC::Shareable', $glue, { %options } or
|
tie %query, 'IPC::Shareable', $GLUE, { %options } or
|
||||||
die "server: tie failed for $glue\n";
|
die "server: tie failed for $GLUE\n";
|
||||||
|
|
||||||
%query = ();
|
%query = ();
|
||||||
|
|
||||||
my %beancountData;
|
my %beancountData;
|
||||||
tie %beancountData, 'IPC::Shareable', $glue, { %options } or
|
tie %beancountData, 'IPC::Shareable', $GLUE, { %options } or
|
||||||
die "server: tie failed\n";
|
die "server: tie failed\n";
|
||||||
|
|
||||||
my ($currentFormat, $runningBeanQuery);
|
my ($currentFormat, $runningBeanQuery);
|
||||||
|
@ -132,7 +134,7 @@ sub StartRunningBeanQuery {
|
||||||
$tempRepository->run(clean => '-fx', { quiet => 1 });
|
$tempRepository->run(clean => '-fx', { quiet => 1 });
|
||||||
$tempRepository->run(reset => '--hard', { quiet => 1 });
|
$tempRepository->run(reset => '--hard', { quiet => 1 });
|
||||||
$tempRepository->run(clean => '-fx', { quiet => 1 });
|
$tempRepository->run(clean => '-fx', { quiet => 1 });
|
||||||
} else {
|
} elsif ($CLEAR_FILES) {
|
||||||
my(@findCmd) = ("/usr/bin/find", '.', '-name', '*.picklecache');
|
my(@findCmd) = ("/usr/bin/find", '.', '-name', '*.picklecache');
|
||||||
if ($VERBOSE > 4) {
|
if ($VERBOSE > 4) {
|
||||||
print STDERR "Cleared the following picklecache files (none listed means none existed)...\n";
|
print STDERR "Cleared the following picklecache files (none listed means none existed)...\n";
|
||||||
|
|
Loading…
Reference in a new issue