[Bps-public-commit] r15496 - in Prophet/branches/dispatcher: lib/Prophet lib/Prophet/CLI
sartak at bestpractical.com
sartak at bestpractical.com
Tue Aug 26 13:41:59 EDT 2008
Author: sartak
Date: Tue Aug 26 13:41:59 2008
New Revision: 15496
Modified:
Prophet/branches/dispatcher/ (props changed)
Prophet/branches/dispatcher/lib/Prophet/CLI.pm
Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
Log:
r70395 at onn: sartak | 2008-08-26 13:41:50 -0400
Switch to using context in the dispatcher
Modified: Prophet/branches/dispatcher/lib/Prophet/CLI.pm
==============================================================================
--- Prophet/branches/dispatcher/lib/Prophet/CLI.pm (original)
+++ Prophet/branches/dispatcher/lib/Prophet/CLI.pm Tue Aug 26 13:41:59 2008
@@ -88,11 +88,13 @@
# yeah this kind of sucks but there's no sane way to tell
my $class;
my %dispatcher_args = (
+ cli => $self,
+ context => $self->context,
got_command => sub { $class = shift },
dispatching_on => $self->context->primary_commands,
);
- $self->dispatcher->run($command, $self, %dispatcher_args);
+ $self->dispatcher->run($command, %dispatcher_args);
die "I don't know how to parse '$command'. Are you sure that's a valid command?" unless $class;
Modified: Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
==============================================================================
--- Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm (original)
+++ Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm Tue Aug 26 13:41:59 2008
@@ -5,13 +5,12 @@
# "ticket display $ID" -> "ticket display --id=$ID"
on qr{ (.*) \s+ ( \d+ | [A-Z0-9]{36} ) $ }x => sub {
- my $cli = shift;
- $cli->set_arg(id => $2);
- run($1, $cli, @_);
+ my %args = @_;
+ $args{cli}->set_arg(id => $2);
+ run($1, %args);
};
on qr{^(\w+)} => sub {
- my $cli = shift;
my %args = @_;
my $cmd = __PACKAGE__->resolve_builtin_aliases($1);
@@ -21,6 +20,8 @@
"Prophet::CLI::Command::Notound",
);
+ my $cli = $args{cli};
+
for my $class (@possible_classes) {
if ($cli->_try_to_load_cmd_class($class)) {
return $args{got_command}->($class);
More information about the Bps-public-commit
mailing list