« blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Plugin/Now.pm
↑ Summary
blib/lib/auto/share/dist/Cmd-Dwarf/app/lib/Dwarf/Plugin/Text/Xslate.pm »
| 1 | package Dwarf::Plugin::Proctitle; | ||
| 2 | use Dwarf::Pragma; | ||
| 3 | use Dwarf::Util qw/add_method load_class/; | ||
| 4 | use Config; | ||
| 5 | |||
| 6 | sub init { | ||
| 7 | my ($class, $c, $conf) = @_; | ||
| 8 | $conf ||= {}; | ||
| 9 | |||
| 10 | $c->add_trigger('BEFORE_DISPATCH' => sub { | ||
| 11 | my $self = shift; | ||
| 12 | my $controller = $self->route->{controller}; | ||
| 13 | _proctitle(sprintf "[Dwarf] %s::%s() (%s)", $controller, lc $self->method, $self->base_dir); | ||
| 14 | }); | ||
| 15 | |||
| 16 | $c->add_trigger('AFTER_DISPATCH' => sub { | ||
| 17 | my $self = shift; | ||
| 18 | _proctitle(sprintf "[Dwarf] idle (%s)", $self->base_dir); | ||
| 19 | }); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub _proctitle { | ||
| 23 | my ($title) = @_; | ||
| 24 | $title ||= $0; | ||
| 25 | $0 = $title; | ||
| 26 | } | ||
| 27 | |||
| 28 | 1; |