Adds --help|-h options; shows usage message and exits 0 if no arguments

This commit is contained in:
Jed Reynolds
2017-10-16 19:00:55 -07:00
parent c1a982d072
commit 41fe0661e5
5 changed files with 96 additions and 52 deletions

View File

@@ -1475,6 +1475,11 @@ sub initStationAddr {
## ----- ----- ----- ----- ----- ----- ----- ----- ----- -----
my $help;
if (@ARGV < 2) {
print $usage;
exit 0;
}
GetOptions
(
'mgr|m=s' => \$::lfmgr_host,

View File

@@ -55,9 +55,15 @@ Example:
$0 --mgr 192.168.100.138 --action set_atten --atten_serno 3 --atten_idx all --atten_val 550\n";
my $i = 0;
my $show_help = 0;
if (@ARGV < 2) {
print $usage;
exit 0;
}
GetOptions
(
'help|h' => \$show_help,
'atten_serno|s=s' => \$atten_serno,
'atten_idx|i=s' => \$atten_idx,
'atten_val|v=s' => \$atten_val,
@@ -70,6 +76,10 @@ GetOptions
) || (print($usage) && exit(1));
if ($show_help) {
print $usage;
exit 0;
}
if ($do_cmd ne "NA") {
$action = "do_cmd";

View File

@@ -150,11 +150,18 @@ Example:
my $i = 0;
my $cmd;
die($::usage) if (@ARGV < 2);
my $log_cli = "unset"; # use ENV{LOG_CLI} elsewhere
my $show_help = 0;
if (@ARGV < 2) {
print $usage;
exit 0;
}
GetOptions
(
'help|h' => \$show_help,
'endp_name|e=s' => \$::endp_name,
'endp_cmd=s' => \$::endp_cmd,
'endp_vals|o=s' => \$::endp_vals,
@@ -186,6 +193,11 @@ GetOptions
'log_cli=s{0,1}'=> \$log_cli,
) || die("$::usage");
if ($show_help) {
print $usage;
exit 0;
}
if ($::quiet eq "0") {
$::quiet = "no";
}

View File

@@ -83,6 +83,7 @@ my $i = 0;
GetOptions
(
'help|h' => \$show_help,
'endp_name|e=s' => \$endp_name,
'speed|s=i' => \$speed,
'cx|c=s' => \$cx,
@@ -95,9 +96,13 @@ GetOptions
'load|L=s' => \$load,
'state|S=s' => \$state,
'quiet|q=i' => \$quiet,
) || die("$usage");
if ($show_help) {
print $usage;
exit 0;
}
if (! ($quiet == 0xffff)) {
open(CMD_LOG, ">$cmd_log_name") or die("Can't open $cmd_log_name for writing...\n");
if (! ($quiet & 0x2)) {

View File

@@ -94,6 +94,7 @@ my $usage = "$0 --port_name {name | number}
[--eap_identity {value|[BLANK]}]
[--eap_passwd {value|[BLANK]}]
[--log_file {value}] # disabled by default
[--help|-h ] # show help
Examples:
./lf_portmod.pl --manager 192.168.1.101 --card 1 --port_name eth2 --show_port
@@ -110,9 +111,15 @@ Examples:
my $i = 0;
my $log_cli = 'unset';
my $show_help = 0;
if (@ARGV < 2) {
print $usage;
exit 0;
}
GetOptions
(
'help|h' => \$show_help,
'ap=s' => \$ap,
'port_name|e=s' => \$port_name,
'cmd|c=s' => \$cmd,
@@ -145,6 +152,11 @@ GetOptions
$::quiet = "yes";
}
if ($show_help) {
print $usage;
exit 0
}
# Open connection to the LANforge server.
if (defined $log_cli) {
if ($log_cli ne "unset") {