App-MrShell
view release on metacpan - search on metacpan
view release on metacpan or search on metacpan
package App::MrShell;
use strict;
use warnings;
use Carp;
use POSIX;
use Config::Tiny;
use POE qw( Wheel::Run );
use Term::ANSIColor qw(:constants);
use Text::Balanced;
our $VERSION = '2.0207';
our @DEFAULT_SHELL_COMMAND = (ssh => '-o', 'BatchMode yes', '-o', 'StrictHostKeyChecking no', '-o', 'ConnectTimeout 20', '[%u]-l', '[]%u', '%h');
# new {{{
sub new {
my $class = shift;
my $this = bless { hosts=>[], cmd=>[], _shell_cmd=>[@DEFAULT_SHELL_COMMAND] }, $class;
return $this;
}
# }}}
# _process_space_delimited {{{
sub _process_space_delimited {
my $this = shift;
my $that = shift;
my @output;
while( $that ) {
if( $that =~ m/^\s*['"]/ ) {
my ($tok, $rem) = Text::Balanced::extract_delimited($that, qr(["']));
($tok =~ s/^(['"])// and $tok =~ s/$1$//) or die "internal error processing space delimited";
push @output, $tok;
$that = $rem;
} else {
my ($tok, $rem) = split ' ', $that, 2;
push @output, $tok;
$that = $rem;
}
}
return @output
}
# }}}
# _process_hosts {{{
sub _process_hosts {
my $this = shift;
my @h = do {
my @tmp = map { my $k = $_; $k =~ s/^\@// ? @{$this->{groups}{$k} or die "couldn't find group: \@$k\n"} : $_ } @_;
my %h; @h{@tmp} = ();
for(keys %h) {
if(my ($k) = m/^\-(.+)/) {
delete $h{$_};
delete $h{$k};
}
}
sort keys %h;
};
my $o = my $l = $this->{_host_width} || 0;
for( map { length $this->_host_route_to_nick($_) } @h ) {
$l = $_ if $_>$l
}
$this->{_host_width} = $l if $l != $o;
return @h;
view all matches for this distributionview release on metacpan - search on metacpan
( run in 1.013 second using v1.00-cache-2.02-grep-82fe00e-cpan-2c419f77a38b )