… | |
… | |
118 | |
118 | |
119 | use Coro (); |
119 | use Coro (); |
120 | use Coro::Handle (); |
120 | use Coro::Handle (); |
121 | use Coro::State (); |
121 | use Coro::State (); |
122 | use Coro::AnyEvent (); |
122 | use Coro::AnyEvent (); |
|
|
123 | use Coro::Timer (); |
123 | |
124 | |
124 | our $VERSION = 5.132; |
125 | our $VERSION = 5.132; |
125 | |
126 | |
126 | our %log; |
127 | our %log; |
127 | our $SESLOGLEVEL = exists $ENV{PERL_CORO_DEFAULT_LOGLEVEL} ? $ENV{PERL_CORO_DEFAULT_LOGLEVEL} : -1; |
128 | our $SESLOGLEVEL = exists $ENV{PERL_CORO_DEFAULT_LOGLEVEL} ? $ENV{PERL_CORO_DEFAULT_LOGLEVEL} : -1; |
… | |
… | |
421 | last; |
422 | last; |
422 | |
423 | |
423 | } elsif ($cmd =~ /^(?:ll|loglevel)\s*(\d+)?\s*/) { |
424 | } elsif ($cmd =~ /^(?:ll|loglevel)\s*(\d+)?\s*/) { |
424 | $loglevel = defined $1 ? $1 : -1; |
425 | $loglevel = defined $1 ? $1 : -1; |
425 | |
426 | |
|
|
427 | } elsif ($cmd =~ /^(?:w|watch)\s*([0-9.]*)\s+(.*)/) { |
|
|
428 | my ($time, $cmd) = ($1*1 || 1, $2); |
|
|
429 | my $cancel; |
|
|
430 | |
|
|
431 | Coro::async { |
|
|
432 | $Coro::current->{desc} = "watch $cmd"; |
|
|
433 | select $fh; |
|
|
434 | until ($cancel) { |
|
|
435 | command $cmd; |
|
|
436 | Coro::Timer::sleep $time; |
|
|
437 | } |
|
|
438 | }; |
|
|
439 | |
|
|
440 | $fh->readable; |
|
|
441 | $cancel = 1; |
|
|
442 | |
426 | } elsif ($cmd =~ /^help\s*/) { |
443 | } elsif ($cmd =~ /^help\s*/) { |
427 | command $cmd; |
444 | command $cmd; |
428 | print <<EOF; |
445 | print <<EOF; |
429 | loglevel <int> enable logging for messages of level <int> and lower |
446 | loglevel <int> enable logging for messages of level <int> and lower |
|
|
447 | watch <time> <command> repeat the given command until STDIN becomes readable |
430 | exit end this session |
448 | exit end this session |
431 | EOF |
449 | EOF |
432 | } else { |
450 | } else { |
433 | command $cmd; |
451 | command $cmd; |
434 | } |
452 | } |