summaryrefslogtreecommitdiff
path: root/docs/cmdline-opts/gen.pl
diff options
context:
space:
mode:
Diffstat (limited to 'docs/cmdline-opts/gen.pl')
-rwxr-xr-xdocs/cmdline-opts/gen.pl50
1 files changed, 47 insertions, 3 deletions
diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl
index 0c434dac9..3fec1646d 100755
--- a/docs/cmdline-opts/gen.pl
+++ b/docs/cmdline-opts/gen.pl
@@ -43,6 +43,7 @@ my %helplong;
my %arglong;
my %redirlong;
my %protolong;
+my %catlong;
# get the long name version, return the man page string
sub manpageify {
@@ -126,6 +127,7 @@ sub single {
my $arg;
my $mutexed;
my $requires;
+ my $category;
my $seealso;
my $magic; # cmdline special option
while(<F>) {
@@ -159,6 +161,9 @@ sub single {
elsif(/^Requires: *(.*)/i) {
$requires=$1;
}
+ elsif(/^Category: *(.*)/i) {
+ $category=$1;
+ }
elsif(/^Help: *(.*)/i) {
;
}
@@ -166,6 +171,9 @@ sub single {
if(!$long) {
print STDERR "WARN: no 'Long:' in $f\n";
}
+ if(!$category) {
+ print STDERR "WARN: no 'Category:' in $f\n";
+ }
last;
}
else {
@@ -274,6 +282,7 @@ sub getshortlong {
my $help;
my $arg;
my $protocols;
+ my $category;
while(<F>) {
if(/^Short: (.)/i) {
$short=$1;
@@ -290,6 +299,9 @@ sub getshortlong {
elsif(/^Protocols: (.*)/i) {
$protocols=$1;
}
+ elsif(/^Category: (.*)/i) {
+ $category=$1;
+ }
elsif(/^---/) {
last;
}
@@ -303,6 +315,7 @@ sub getshortlong {
$helplong{$long}=$help;
$arglong{$long}=$arg;
$protolong{$long}=$protocols;
+ $catlong{$long}=$category;
}
}
@@ -328,6 +341,8 @@ sub listhelp {
foreach my $f (sort keys %helplong) {
my $long = $f;
my $short = $optlong{$long};
+ my @categories = split ' ', $catlong{$long};
+ my $bitmask;
my $opt;
if(defined($short) && $long) {
@@ -336,7 +351,13 @@ sub listhelp {
elsif($long && !$short) {
$opt = " --$long";
}
-
+ for my $i (0 .. $#categories) {
+ $bitmask .= 'CURLHELP_' . uc $categories[$i];
+ # If not last element, append |
+ if($i < $#categories) {
+ $bitmask .= ' | ';
+ }
+ }
my $arg = $arglong{$long};
if($arg) {
$opt .= " $arg";
@@ -344,7 +365,7 @@ sub listhelp {
my $desc = $helplong{$f};
$desc =~ s/\"/\\\"/g; # escape double quotes
- my $line = sprintf " {\"%s\",\n \"%s\"},\n", $opt, $desc;
+ my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask;
if(length($opt) + length($desc) > 78) {
print STDERR "WARN: the --$long line is too long\n";
@@ -353,6 +374,25 @@ sub listhelp {
}
}
+sub listcats {
+ my %allcats;
+ foreach my $f (sort keys %helplong) {
+ my @categories = split ' ', $catlong{$f};
+ foreach (@categories) {
+ $allcats{$_} = undef;
+ }
+ }
+ my @categories;
+ foreach my $key (keys %allcats) {
+ push @categories, $key;
+ }
+ @categories = sort @categories;
+ unshift @categories, 'hidden';
+ for my $i (0..$#categories) {
+ print '#define ' . 'CURLHELP_' . uc($categories[$i]) . ' ' . "1u << " . $i . "u\n";
+ }
+}
+
sub mainpage {
my (@files) = @_;
# show the page header
@@ -406,8 +446,12 @@ sub getargs {
showprotocols();
return;
}
+ elsif($f eq "listcats") {
+ listcats();
+ return;
+ }
- print "Usage: gen.pl <mainpage/listhelp/single FILE/protos> [files]\n";
+ print "Usage: gen.pl <mainpage/listhelp/single FILE/protos/listcats> [files]\n";
}
#------------------------------------------------------------------------