File: lsopts.pl

package info (click to toggle)
feh 3.11.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,540 kB
  • sloc: ansic: 13,134; perl: 968; makefile: 221; sh: 37
file content (32 lines) | stat: -rwxr-xr-x 564 bytes parent folder | download | duplicates (8)
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},
	);
}