summaryrefslogtreecommitdiff
path: root/utils/cli/ledgersmb_cli.pl
blob: 1dbbf2fa4e25adfc0ad019963085169ea5513588 (plain)
  1. #!/usr/bin/perl
  2. # This is a simple wrapper that allows you to write simple scripts with LSMB
  3. # See sample for the file format.
  4. use LedgerSMB::User;
  5. use LedgerSMB::Form;
  6. use LedgerSMB::Sysconfig;
  7. $form = new Form;
  8. while ($line = <>){
  9. $line =~ s/#.*//; # strip out comments
  10. if ($line =~ /^\s*CALL (.+) INTO (.+)/){
  11. $form->{$2} = &{$1}(\%$form);
  12. } elsif ($line =~ /^\s*MODULE (.+)/){
  13. $module = $1;
  14. $module =~ s/::/\//;
  15. eval { require $module; };
  16. } elsif ($line =~ /^\s*ENV:(.+)\s*=\s*(.*)/){
  17. $ENV{$1} = $2;
  18. } elsif ($line =~ /^\s*(.+)\s*=\s*(.+)/){
  19. $form->{$1} = $2;
  20. } elsif ($line =~ /^\s*CALL (.+)/){
  21. &{$1}(\%$form);
  22. } elsif ($line !~ /^\s*$/) {
  23. die "Parse error in script file: $line";
  24. }
  25. }
  26. for (keys %$form){
  27. print "$_ = $form->{$_}\n";
  28. }