]>
Commit | Line | Data |
---|---|---|
f4101aa6 AD |
1 | #! /usr/bin/env perl |
2 | ||
3 | use warnings; | |
4 | use 5.005; | |
5 | use strict; | |
6 | ||
7 | my %option; | |
8 | while (<>) | |
9 | { | |
7020f1e9 AD |
10 | if (/^\s* # Initial spaces. |
11 | (?:(-\w),\s+)? # $1: Possible short option. | |
12 | (--[-\w]+) # $2: Long option. | |
13 | (\[?) # $3: '[' iff the argument is optional. | |
14 | (?:=([-\w]+))? # $4: Possible argument name. | |
15 | /x) | |
f4101aa6 AD |
16 | { |
17 | my ($short, $long, $opt, $arg) = ($1, $2, $3, $4); | |
18 | $short = defined $short ? '@option{' . $short . '}' : ''; | |
19 | if ($arg) | |
20 | { | |
21 | $arg =~ s/^=//; | |
22 | $arg = '@var{' . lc ($arg) . '}'; | |
23 | $arg = '[' . $arg . ']' | |
7020f1e9 | 24 | if $opt eq '['; |
1bb2bd75 | 25 | $option{"$long=$arg"} = $short ? "$short $arg" : ''; |
f4101aa6 AD |
26 | } |
27 | else | |
28 | { | |
29 | $option{"$long"} = "$short"; | |
30 | } | |
31 | } | |
32 | } | |
33 | ||
34 | foreach my $long (sort keys %option) | |
35 | { | |
36 | printf "\@item %-40s \@tab %s\n", '@option{' . $long . '}', $option{$long}; | |
37 | } |