cshelper now works now all appears to be a question of finishing the docs

This commit is contained in:
Zane C. B-H 2020-02-03 06:18:57 -06:00
parent 7265d2a1ad
commit 1b1eb90bbc
3 changed files with 17 additions and 3 deletions

View File

@ -17,7 +17,6 @@ my %WriteMakefileArgs = (
'Test::More' => '0',
},
PREREQ_PM => {
'SNMP' => '5.0404',
'Config::Tiny' => '2.24',
'Stirng::ShellQuote' => '1.04',
'File::BaseDir' => '0.08',

View File

@ -20,6 +20,7 @@ sub help{
-c <file> Config file.
-h <file> Hosts file.
-m <method> Selection to use.
-p Print the final command before running it.
';
}
@ -30,15 +31,19 @@ if (!defined( $ARGV[0] )) {
my $config_file;
my $hosts_file;
my $method;
my $print_cmd;
my $command=join(' ', @ARGV);
# get the commandline options
Getopt::Long::Configure ('no_ignore_case');
Getopt::Long::Configure ('bundling');
Getopt::Long::Configure ('pass_through');
Getopt::Long::Configure ('require_order');
GetOptions(
'c=s'=>\$config_file,
'h=s'=>\$hosts_file,
'm=s'=>\$method,
'p'=>\$print_cmd,
);
my $csh=Cluster::SSH::Helper->new_from_ini( $config_file, $hosts_file );
@ -46,4 +51,5 @@ my $csh=Cluster::SSH::Helper->new_from_ini( $config_file, $hosts_file );
$csh->run({
command=>\@ARGV,
method=>$method,
print_cmd=>$print_cmd,
});

View File

@ -5,7 +5,6 @@ use strict;
use warnings;
use Config::Tiny;
use String::ShellQuote;
use SNMP;
use File::BaseDir qw/xdg_config_home/;
=head1 NAME
@ -177,6 +176,10 @@ This is the selector method to use if not using the default.
If set to true, returns the command in question after figuring out what it is.
=head3 print_cmd
Prints the command before running it.
eval({
$csh->run({
command=>'uname -a',
@ -294,7 +297,13 @@ sub run {
return $command;
}
print $command."\n";
if (
defined($opts->{print_cmd}) &&
$opts->{print_cmd}
) {
print $command."\n";
}
system($command);
return $?;