add debug support

This commit is contained in:
Zane C. B-H 2020-02-03 06:26:21 -06:00
parent 623e93c015
commit 861c55a9e1
1 changed files with 34 additions and 21 deletions

View File

@ -11,45 +11,58 @@ use warnings;
use Cluster::SSH::Helper;
use Getopt::Long;
sub version{
print "cshelper v. 0.1.0\n";
sub version {
print "cshelper v. 0.1.0\n";
}
sub help{
print '
sub help {
print '
-c <file> Config file.
-h <file> Hosts file.
-m <method> Selection to use.
-d Only print the command to run and exit.
-p Print the final command before running it.
';
}
if (!defined( $ARGV[0] )) {
die("Nothing specified to execute");
if ( !defined( $ARGV[0] ) ) {
die("Nothing specified to execute");
}
my $config_file;
my $hosts_file;
my $method;
my $print_cmd;
my $command=join(' ', @ARGV);
my $debug;
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');
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,
'c=s' => \$config_file,
'h=s' => \$hosts_file,
'm=s' => \$method,
'p' => \$print_cmd,
'd' => \$debug,
);
my $csh=Cluster::SSH::Helper->new_from_ini( $config_file, $hosts_file );
my $csh = Cluster::SSH::Helper->new_from_ini( $config_file, $hosts_file );
exit $csh->run({
command=>\@ARGV,
method=>$method,
print_cmd=>$print_cmd,
});
my $return = $csh->run(
{
command => \@ARGV,
method => $method,
print_cmd => $print_cmd,
debug => $debug,
}
);
if ($debug) {
print $return."\n";
exit;
}else {
exit $return;
}