mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-03-22 14:39:24 -05:00
logparse.pl: more sensible option-parsing.
Switched to Getopt::Long in place of the previous ad-hockery, which will make it easier to add more (and more complicated) options.
This commit is contained in:
parent
510187a733
commit
204780080d
@ -1,22 +1,25 @@
|
|||||||
#!/usr/bin/perl
|
#!/usr/bin/perl
|
||||||
|
|
||||||
|
use Getopt::Long;
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use FileHandle;
|
use FileHandle;
|
||||||
|
|
||||||
my $dumpchannels = 0;
|
my $dumpchannels = 0;
|
||||||
my $dumpdata = 0;
|
my $dumpdata = 0;
|
||||||
while ($ARGV[0] =~ /^-/) {
|
GetOptions("dump-channels|c" => \$dumpchannels,
|
||||||
my $opt = shift @ARGV;
|
"dump-data|d" => \$dumpdata,
|
||||||
if ($opt eq "--") {
|
"help" => sub { &usage(\*STDOUT, 0); })
|
||||||
last; # stop processing options
|
or &usage(\*STDERR, 1);
|
||||||
} elsif ($opt eq "-c") {
|
|
||||||
$dumpchannels = 1;
|
sub usage {
|
||||||
} elsif ($opt eq "-d") {
|
my ($fh, $exitstatus) = @_;
|
||||||
$dumpdata = 1;
|
print $fh <<'EOF';
|
||||||
} else {
|
usage: logparse.pl [ options ] [ input-log-file ]
|
||||||
die "unrecognised option '$opt'\n";
|
options: --dump-channels, -c dump the final state of every channel
|
||||||
}
|
--dump-data, -d save data of every channel to ch0.i, ch0.o, ...
|
||||||
|
EOF
|
||||||
|
exit $exitstatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
my @channels = (); # ultimate channel ids are indices in this array
|
my @channels = (); # ultimate channel ids are indices in this array
|
||||||
|
Loading…
x
Reference in New Issue
Block a user