aboutsummaryrefslogtreecommitdiff
path: root/docs/cmdline-opts/gen.pl
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2016-11-15 09:08:50 +0100
committerDaniel Stenberg <daniel@haxx.se>2016-11-15 09:08:50 +0100
commitb8c35f40f99cd1965d6e3152fc01071b73c3d2f1 (patch)
tree508893b8a3d421e4c31e288de0871e4e1a2ada8b /docs/cmdline-opts/gen.pl
parent7c9b9add6ff5626fc8712d8f8b4e607dcbe8dbfe (diff)
cmdline-opts: support generating the --help output
Diffstat (limited to 'docs/cmdline-opts/gen.pl')
-rwxr-xr-xdocs/cmdline-opts/gen.pl69
1 files changed, 62 insertions, 7 deletions
diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl
index ae52bfa84..9bdfa4c31 100755
--- a/docs/cmdline-opts/gen.pl
+++ b/docs/cmdline-opts/gen.pl
@@ -8,6 +8,8 @@ closedir $dh;
my %optshort;
my %optlong;
+my %helplong;
+my %arglong;
# get the long name version, return the man page string
sub manpageify {
@@ -165,7 +167,8 @@ sub getshortlong {
open(F, "<$f");
my $short;
my $long;
-
+ my $help;
+ my $arg;
while(<F>) {
if(/^Short: (.)/i) {
$short=$1;
@@ -173,6 +176,12 @@ sub getshortlong {
elsif(/^Long: (.*)/i) {
$long=$1;
}
+ elsif(/^Help: (.*)/i) {
+ $help=$1;
+ }
+ elsif(/^Arg: (.*)/i) {
+ $arg=$1;
+ }
elsif(/^---/) {
last;
}
@@ -183,6 +192,8 @@ sub getshortlong {
}
if($long) {
$optlong{$long}=$short;
+ $helplong{$long}=$help;
+ $arglong{$long}=$arg;
}
}
@@ -202,15 +213,59 @@ sub header {
printdesc(@d);
}
+sub listhelp {
+ foreach my $f (sort keys %helplong) {
+ my $long = $f;
+ my $short = $optlong{$long};
+ my $opt;
+
+ if(defined($short) && $long) {
+ $opt = "-$short, --$long";
+ }
+ elsif($long && !$short) {
+ $opt = " --$long";
+ }
+
+ my $arg = $arglong{$long};
+ if($arg) {
+ $opt .= " $arg";
+ }
+
+ printf " %-19s %s\n", $opt, $helplong{$f};
+ }
+}
+
+sub mainpage {
+ # show the page header
+ header();
+
+ # output docs for all options
+ foreach my $f (sort @s) {
+ single($f);
+ }
+}
+
+sub getargs {
+ my $f;
+ do {
+ $f = shift @ARGV;
+ if($f eq "mainpage") {
+ mainpage();
+ return;
+ }
+ elsif($f eq "listhelp") {
+ listhelp();
+ return;
+ }
+ } while($f);
+
+ print "Usage: gen.pl <mainpage/listhelp>\n";
+}
+
#------------------------------------------------------------------------
# learn all existing options
indexoptions();
-# show the page header
-header();
+getargs();
-# output docs for all options
-foreach my $f (sort @s) {
- single($f);
-}