summaryrefslogtreecommitdiff
path: root/scripts/lsopts.pl
blob: 1ea8aafa40fcb79aedb23023e8b6b08c8674d6b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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},
	);
}