summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-07-09 11:20:11 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-07-09 11:20:11 +0200
commite13301d07dc117273b10e8f372e3e65ef7349120 (patch)
tree9b13ff2d18faa80e7dae6a74b7c092a814b24679
parenta71200150bd7e5dfd777fdca916f138ab69ea71a (diff)
Add scripts/lsopts.pl (list short/long option pairs)
-rwxr-xr-xscripts/lsopts.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/lsopts.pl b/scripts/lsopts.pl
new file mode 100755
index 0000000..1ea8aaf
--- /dev/null
+++ b/scripts/lsopts.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+
+my %opts;
+
+for my $chr ('a' .. 'z', 'A' .. 'Z') {
+ $opts{$chr} = q{};
+}
+
+open(my $fh, '<', 'src/options.c') or die("Can't open options.c: $!");
+while (my $line = <$fh>) {
+ chomp($line);
+ if ($line =~ /\{"(?<long>[^"]+)"\s*,.+,.+, (?<short>...)/) {
+ if (substr($+{'short'}, 0, 1) eq '\'') {
+ $opts{substr($+{'short'}, 1, 1)} = $+{'long'};
+ }
+ else {
+ $opts{$+{'short'}} = $+{'long'};
+ }
+ }
+}
+close($fh);
+
+foreach my $short (sort keys %opts) {
+ printf(
+ "%s\t%s\n",
+ $short,
+ $opts{$short},
+ );
+}