X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=scripts%2Fconsole;h=bf4ffaa6c8fb05b16c2e47b77e6cbdb07c51377a;hb=2b9a68bb2041ebde41a7c52db436efc8dde06350;hp=8ce978346329df8645bc85bd65d879012b211a8f;hpb=72033e2d36d055046a58fb19574ce293d53f65d6;p=kivitendo-erp.git diff --git a/scripts/console b/scripts/console index 8ce978346..bf4ffaa6c 100755 --- a/scripts/console +++ b/scripts/console @@ -2,11 +2,16 @@ use warnings; use strict; +use utf8; +use open qw(:std :utf8); use 5.008; # too much magic in here to include perl 5.6 BEGIN { - unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). - push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version. + use FindBin; + + unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). + push (@INC, $FindBin::Bin . '/..'); + push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. } use Data::Dumper; @@ -14,7 +19,6 @@ use Devel::REPL 1.002001; use File::Slurp; use Getopt::Long; use Pod::Usage; -use Term::ReadLine::Perl::Bind; # use sane key binding for rxvt users use SL::LxOfficeConf; SL::LxOfficeConf->read; @@ -62,6 +66,10 @@ sub execute_code { my $repl = Devel::REPL->new; $repl->load_plugin($_) for @plugins; $repl->load_history($history_file); + +binmode($repl->out_fh, 'utf8'); + +$repl->eval('use utf8;'); $repl->eval('help'); $repl->print("trying to auto login into client '$client' with login '$login'...\n"); execute_code($repl, "lxinit '$client', '$login'"); @@ -85,6 +93,7 @@ use SL::Locale; use SL::LXDebug; use Data::Dumper; use List::Util qw(max); +use Time::HiRes; # this is a cleaned up version of am.pl # it lacks redirection, some html setup and most of the authentication process. @@ -117,9 +126,8 @@ sub lxinit { die "cannot find user $login" unless %::myconfig = $::auth->read_user(login => $login); - $::form->{login} = $login; # normaly implicit at login - die "cannot find locale for user $login" unless $::locale = Locale->new($::myconfig{countrycode}); + $::myconfig{login} = $login; # so SL::DB::Manager::Employee->current works in test database $::instance_conf->init; @@ -154,11 +162,18 @@ sub help { Spezielle Kommandos: - help - zeigt diese Hilfe an. - lxinit 'login' - lädt das kivitendo-Environment für den User 'login'. - reload - lädt modifizierte Module neu. - pp DATA - zeigt die Datenstruktur mit Data::Dumper an. - quit - beendet die Konsole + help - zeigt diese Hilfe an. + lxinit 'login' - lädt das kivitendo-Environment für den User 'login'. + reload - lädt modifizierte Module neu. + pp DATA - zeigt die Datenstruktur mit Data::Dumper an. + clock { CODE } - zeigt die gebrauchte Zeit für die Ausführung von CODE an + quit - beendet die Konsole + + part - shortcuts auf die jeweilige SL::DB::{...}::find_by + customer, vendor, + order, invoice, + purchase_invoice, + chart EOL # load 'module' - läd das angegebene Modul, d.h. bin/mozilla/module.pl und SL/Module.pm. @@ -208,6 +223,48 @@ sub sql { } } +sub part { + require SL::DB::Part; + SL::DB::Manager::Part->find_by(@_) +} + +sub order { + require SL::DB::Order; + SL::DB::Manager::Order->find_by(@_) +} + +sub invoice { + require SL::DB::Invoice; + SL::DB::Manager::Invoice->find_by(@_) +} + +sub purchase_invoice { + require SL::DB::PurchaseInvoice; + SL::DB::Manager::PurchaseInvoice->find_by(@_) +} + +sub customer { + require SL::DB::Customer; + SL::DB::Manager::Customer->find_by(@_) +} + +sub vendor { + require SL::DB::Vendor; + SL::DB::Manager::Vendor->find_by(@_) +} + +sub chart { + require SL::DB::Chart; + SL::DB::Manager::Chart->find_by(@_) +} + +sub clock (&) { + my $s = [Time::HiRes::gettimeofday()]; + $_[0]->(); + Time::HiRes::tv_interval($s); +} + + 1; __END__ @@ -240,6 +297,12 @@ Print the manual page and exit. Log in as C. The default is to use the value from the configuration file and C if none is set there. +=item B<-c>, B<--client>=C + +Use the database for client C. C can be a client's +database ID or its name. The default is to use the value from the +configuration file. + =item B<-o>, B<--log-file>=C Use C as the log file. The default is to use the value from