1 2# DO NOT EDIT THE FOLLOWING 3# 4# It's auto generated option handling code 5 6use Getopt::Long qw(GetOptionsFromArray); 7Getopt::Long::Configure(qw(no_auto_abbrev no_ignore_case_always)); 8 9my $usage; 10 11sub usage { 12 my ($ret) = @_; 13 print STDERR $usage; 14 exit $ret; 15} 16 17sub paged_usage { 18 my ($ret) = @_; 19 my $pager = $ENV{PAGER} || '(less || more)'; 20 21 open STDOUT, "| $pager" or die "Can't fork a pager: $!"; 22 print $usage; 23 24 exit $ret; 25} 26 27sub processOptions { 28 my $args = shift; 29 30 my $opts = { 31 'tries' => '100', 32 'sleep' => '6', 33 'verbose' => '', 34 'help' => '', 'more-help' => '' 35 }; 36 my $argument = ''; 37 my $ret = GetOptionsFromArray($args, $opts, ( 38 'tries|n=i', 'sleep|s=i', 'verbose|v', 39 'help|?', 'more-help')); 40 41 $usage = <<'USAGE'; 42ntp-wait - Wait for ntpd to stabilize the system clock 43USAGE: ntp-wait [ -<flag> [<val>] | --<name>[{=| }<val>] ]... 44 45 -n, --tries=num Number of times to check ntpd 46 -s, --sleep=num How long to sleep between tries 47 -v, --verbose Be verbose 48 -?, --help Display usage information and exit 49 , --more-help Pass the extended usage information through a pager 50 51Options are specified by doubled hyphens and their name or by a single 52hyphen and the flag character. 53USAGE 54 55 usage(0) if $opts->{'help'}; 56 paged_usage(0) if $opts->{'more-help'}; 57 $_[0] = $opts; 58 return $ret; 59} 60 61END { close STDOUT }; 62 63