summaryrefslogtreecommitdiff
path: root/utils/cli/ledgersmb_cli.pl
blob: b5ed3d922d29081fd634a7281184754950537918 (plain)
  1. #!/usr/bin/perl
  2. #===========================================================================
  3. #
  4. # LedgerSMB Command-line script host
  5. #
  6. #
  7. # LedgerSMB
  8. # Small Medium Business Accounting software
  9. # http://www.ledgersmb.org/
  10. #
  11. #
  12. # Copyright (C) 2006
  13. # This work contains copyrighted information from a number of sources all used
  14. # with permission. It is released under the GNU General Public License
  15. # Version 2 or, at your option, any later version. See COPYRIGHT file for
  16. # details.
  17. #
  18. # This is a simple wrapper that allows you to write simple scripts with LSMB
  19. # See sample for the file format.
  20. use LedgerSMB::User;
  21. use LedgerSMB::Form;
  22. use LedgerSMB::Sysconfig;
  23. $form = new Form;
  24. while ($line = <>){
  25. $line =~ s/#.*//; # strip out comments
  26. if ($line =~ /^\s*CALL (.+) INTO (.+)/){
  27. $form->{$2} = &{$1}(\%$form);
  28. } elsif ($line =~ /^\s*MODULE (.+)/){
  29. $module = $1;
  30. $module =~ s/::/\//;
  31. eval { require $module; };
  32. } elsif ($line =~ /^\s*ENV:(.+)\s*=\s*(.*)/){
  33. $ENV{$1} = $2;
  34. } elsif ($line =~ /^\s*(.+)\s*=\s*(.+)/){
  35. $form->{$1} = $2;
  36. } elsif ($line =~ /^\s*CALL (.+)/){
  37. {$1}(\%$form);
  38. } elsif ($line !~ /^\s*$/) {
  39. die "Parse error in script file: $line";
  40. }
  41. }
  42. for (keys %$form){
  43. print "$_ = $form->{$_}\n";
  44. }