summaryrefslogtreecommitdiff
path: root/utils/cli
diff options
context:
space:
mode:
authoreinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
committereinhverfr <einhverfr@4979c152-3d1c-0410-bac9-87ea11338e46>2007-04-26 18:00:56 +0000
commit666fd833584fe2e3618a397fe9d9a9bdf4c5b94b (patch)
tree19c4444705fd7f7803e0d7b597659c11d7e85b73 /utils/cli
parent2edd2e4de0f08a0a5f23647ea715f279671a0b89 (diff)
Doing a simple Perltidy commit so that I can evaluate differences between the branches and make sure patches are up to date
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1103 4979c152-3d1c-0410-bac9-87ea11338e46
Diffstat (limited to 'utils/cli')
-rw-r--r--utils/cli/ledgersmb_cli.pl134
1 files changed, 69 insertions, 65 deletions
diff --git a/utils/cli/ledgersmb_cli.pl b/utils/cli/ledgersmb_cli.pl
index a8fbaa98..606cfac0 100644
--- a/utils/cli/ledgersmb_cli.pl
+++ b/utils/cli/ledgersmb_cli.pl
@@ -4,15 +4,15 @@
# LedgerSMB Command-line script host
#
#
-# LedgerSMB
+# LedgerSMB
# Small Medium Business Accounting software
# http://www.ledgersmb.org/
-#
+#
#
# Copyright (C) 2006
# This work contains copyrighted information from a number of sources all used
-# with permission. It is released under the GNU General Public License
-# Version 2 or, at your option, any later version. See COPYRIGHT file for
+# with permission. It is released under the GNU General Public License
+# Version 2 or, at your option, any later version. See COPYRIGHT file for
# details.
#
# This is a simple wrapper that allows you to write simple scripts with LSMB
@@ -83,9 +83,10 @@ $syntax = << '_END_SYNTAX_';
_END_SYNTAX_
- $::RD_HINT = 1;
- $::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
- $::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c.`
+$::RD_HINT = 1;
+$::RD_ERRORS = 1; # Make sure the parser dies when it encounters an error
+$::RD_WARN = 1; # Enable warnings. This will warn on unused rules &c.`
+
#$::RD_TRACE = 1;
my @loopstack;
my $loopindex;
@@ -95,97 +96,100 @@ my @control_stack;
push @loopstack, $form;
sub assignval {
- my ($key, $value) = @_;
- if ($key =~ /^ENV:/i){
- $ENV{$key} = $value;
- } else {
- %{$loopstack[$#loopstack - 1]}->{$key} = $value;
- }
+ my ( $key, $value ) = @_;
+ if ( $key =~ /^ENV:/i ) {
+ $ENV{$key} = $value;
+ }
+ else {
+ %{ $loopstack[ $#loopstack - 1 ] }->{$key} = $value;
+ }
}
sub expression {
- shift;
- my ($lhs,$op,$rhs) = @_;
- $lhs = $VARIABLE{$lhs} if $lhs=~/[^-+0-9]/;
- return eval "$lhs $op $rhs";
+ shift;
+ my ( $lhs, $op, $rhs ) = @_;
+ $lhs = $VARIABLE{$lhs} if $lhs =~ /[^-+0-9]/;
+ return eval "$lhs $op $rhs";
}
sub call {
- my ($call, $argstr) = @_;
- $argstr =~ s/form/\\\%\$form/;
- $argstr =~ s/user/\\\%myconfig/;
- my @args = split /,\s/, $argstr;
- eval "$call($argstr);\n" || print STDERR $@ . "\n";
+ my ( $call, $argstr ) = @_;
+ $argstr =~ s/form/\\\%\$form/;
+ $argstr =~ s/user/\\\%myconfig/;
+ my @args = split /,\s/, $argstr;
+ eval "$call($argstr);\n" || print STDERR $@ . "\n";
}
sub call_and_assign {
- my $key = pop;
- $stackref->{key} = call(@_);
+ my $key = pop;
+ $stackref->{key} = call(@_);
}
sub push_loop {
- my $key = shift;
- my $is_hash = 0;
- if (ref($stackref->{$key}) =~ /HASH/){
- $is_hash = 1;
- } elsif (ref ($stackref->{$key}) !~ /ARRAY/){
- print STDERR "Warning: Must loop through array or hash.";
- }
- push @loopstack, \$stackref->{$key};
- push @controlstack,
- { "key" => $key,
- 'index' => 0,
- 'linenum' => $#linestack,
- is_hash => $is_hash };
+ my $key = shift;
+ my $is_hash = 0;
+ if ( ref( $stackref->{$key} ) =~ /HASH/ ) {
+ $is_hash = 1;
+ }
+ elsif ( ref( $stackref->{$key} ) !~ /ARRAY/ ) {
+ print STDERR "Warning: Must loop through array or hash.";
+ }
+ push @loopstack, \$stackref->{$key};
+ push @controlstack,
+ {
+ "key" => $key,
+ 'index' => 0,
+ 'linenum' => $#linestack,
+ is_hash => $is_hash
+ };
}
sub pop_loop {
- pop @loopstack;
- $stackref = \$loopstack[$#loopstack];
+ pop @loopstack;
+ $stackref = \$loopstack[$#loopstack];
}
sub if_handler {
- my $key = shift;
- if (!$stackref->{$key}){
- $if_count = 1;
- }
+ my $key = shift;
+ if ( !$stackref->{$key} ) {
+ $if_count = 1;
+ }
}
sub login {
- $myconfig = new LedgerSMB::User
- "${LedgerSMB::Sysconfig::memberfile}", "$form->{login}";
- $form->db_init($myconfig);
+ $myconfig = new LedgerSMB::User "${LedgerSMB::Sysconfig::memberfile}",
+ "$form->{login}";
+ $form->db_init($myconfig);
}
sub load_mod {
- my $mod = shift;
- $mod =~ s/::/\//;
- require "$mod.pm";;
+ my $mod = shift;
+ $mod =~ s/::/\//;
+ require "$mod.pm";
}
my $scriptparse = new Parse::RecDescent($syntax);
-
$loopindex = 0;
my @linestack;
-while ($line = <>){
- push @linestack, $line;
- if ($if_count){
- if ($line =~ /^\s*IF\s/){
- ++$if_count;
- }
- if ($line =~ /^(\s*FI\s*|\s*END\s+IF\s*)$/){
- --$if_count;
- }
- }
- next if ($if_count);
- $line =~ s/#.*$//; # strip comments
- $scriptparse->startrule($line);
+while ( $line = <> ) {
+ push @linestack, $line;
+ if ($if_count) {
+ if ( $line =~ /^\s*IF\s/ ) {
+ ++$if_count;
+ }
+ if ( $line =~ /^(\s*FI\s*|\s*END\s+IF\s*)$/ ) {
+ --$if_count;
+ }
+ }
+ next if ($if_count);
+ $line =~ s/#.*$//; # strip comments
+ $scriptparse->startrule($line);
}
delete $form->{password};
-for (keys %$form){
- print "$_ = $form->{$_}\n";
+for ( keys %$form ) {
+ print "$_ = $form->{$_}\n";
}