add debug support
This commit is contained in:
parent
623e93c015
commit
861c55a9e1
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue