From: Matt S Trout Date: Tue, 15 Nov 2011 07:16:30 +0000 (+0000) Subject: make -l actually work X-Git-Tag: v0.001002~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3c2c021a21c598cfdebd5f361d51726cda4a14ce;p=scpubgit%2FTak.git make -l actually work --- diff --git a/Changes b/Changes index f945916..640da79 100644 --- a/Changes +++ b/Changes @@ -1,2 +1,4 @@ + - Support for -l/--local in Tak::Script + 0.001001 - 2011-11-15 - Initial release diff --git a/lib/Tak/Client/Router.pm b/lib/Tak/Client/Router.pm index 3672ab6..f4c4fff 100644 --- a/lib/Tak/Client/Router.pm +++ b/lib/Tak/Client/Router.pm @@ -8,4 +8,6 @@ sub ensure { shift->do(meta => ensure => @_); } +sub host { 'localhost' } + 1; diff --git a/lib/Tak/Script.pm b/lib/Tak/Script.pm index 446b434..b7a8f5f 100644 --- a/lib/Tak/Script.pm +++ b/lib/Tak/Script.pm @@ -118,12 +118,13 @@ sub _run_local { sub _run_each { my ($self, $cmd, $code, @argv) = @_; my @targets = $self->_host_list_for($cmd); - unless (@targets) { + unless (@targets or $self->options->{local}) { $self->stderr->print("No targets for ${cmd}\n"); return; } my $opt = $self->_maybe_parse_options($code, \@argv); $self->local_client->ensure(connector => 'Tak::ConnectorService'); + $self->$code($self->local_client, $opt, @argv) if $self->options->{local}; foreach my $target (@targets) { my $remote = $self->_connection_to($target); $self->$code($remote, $opt, @argv); @@ -133,13 +134,14 @@ sub _run_each { sub _run_every { my ($self, $cmd, $code, @argv) = @_; my @targets = $self->_host_list_for($cmd); - unless (@targets) { + unless (@targets or $self->options->{local}) { $self->stderr->print("No targets for ${cmd}\n"); return; } my $opt = $self->_maybe_parse_options($code, \@argv); $self->local_client->ensure(connector => 'Tak::ConnectorService'); my @remotes = map $self->_connection_to($_), @targets; + unshift @remotes, $self->local_client if $self->options->{local}; $self->$code(\@remotes, $opt, @argv); }