gen.pl: add '%GLOBALS' as a variable for mainpage

And use it in page-header to list all global command line options.
This commit is contained in:
Daniel Stenberg 2023-02-21 17:17:49 +01:00
parent 86ec17b856
commit ddff8ef706
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
3 changed files with 39 additions and 2 deletions

View file

@ -37,5 +37,5 @@ GN_ = $(GN_0)
all: $(MANPAGE) all: $(MANPAGE)
$(MANPAGE): $(DPAGES) $(OTHERPAGES) Makefile.inc $(MANPAGE): $(DPAGES) $(OTHERPAGES) Makefile.inc gen.pl
$(GEN)(rm -f $(MANPAGE) && cd $(srcdir) && @PERL@ ./gen.pl mainpage $(DPAGES) > $(builddir)/manpage.tmp && mv $(builddir)/manpage.tmp $(MANPAGE)) $(GEN)(rm -f $(MANPAGE) && cd $(srcdir) && @PERL@ ./gen.pl mainpage $(DPAGES) > $(builddir)/manpage.tmp && mv $(builddir)/manpage.tmp $(MANPAGE))

View file

@ -51,6 +51,7 @@ use POSIX qw(strftime);
my $date = strftime "%B %d %Y", localtime; my $date = strftime "%B %d %Y", localtime;
my $year = strftime "%Y", localtime; my $year = strftime "%Y", localtime;
my $version = "unknown"; my $version = "unknown";
my $globals;
open(INC, "<../../include/curl/curlver.h"); open(INC, "<../../include/curl/curlver.h");
while(<INC>) { while(<INC>) {
@ -520,6 +521,7 @@ sub header {
while(<F>) { while(<F>) {
s/%DATE/$date/g; s/%DATE/$date/g;
s/%VERSION/$version/g; s/%VERSION/$version/g;
s/%GLOBALS/$globals/g;
push @d, $_; push @d, $_;
} }
close(F); close(F);
@ -535,7 +537,7 @@ sub listhelp {
* | (__| |_| | _ <| |___ * | (__| |_| | _ <| |___
* \\___|\\___/|_| \\_\\_____| * \\___|\\___/|_| \\_\\_____|
* *
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
* *
* This software is licensed as described in the file COPYING, which * This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms * you should have received as part of this distribution. The terms
@ -629,6 +631,36 @@ sub listcats {
} }
} }
sub listglobals {
my (@files) = @_;
my @globalopts;
# Find all global options and output them
foreach my $f (sort @files) {
open(F, "<:crlf", "$f") ||
next;
my $long;
while(<F>) {
if(/^Long: *(.*)/i) {
$long=$1;
}
elsif(/^Scope: global/i) {
push @globalopts, $long;
last;
}
elsif(/^---/) {
last;
}
}
close(F);
}
return $ret if($ret);
for my $e (0 .. $#globalopts) {
$globals .= sprintf "%s--%s", $e?($globalopts[$e+1] ? ", " : " and "):"",
$globalopts[$e],;
}
}
sub mainpage { sub mainpage {
my (@files) = @_; my (@files) = @_;
my $ret; my $ret;
@ -669,6 +701,7 @@ sub showprotocols {
sub getargs { sub getargs {
my ($f, @s) = @_; my ($f, @s) = @_;
if($f eq "mainpage") { if($f eq "mainpage") {
listglobals(@s);
mainpage(@s); mainpage(@s);
return; return;
} }

View file

@ -201,3 +201,7 @@ prefix it with "no-". However, in this list we mostly only list and show the
When --next is used, it resets the parser state and you start again with a When --next is used, it resets the parser state and you start again with a
clean option state, except for the options that are "global". Global options clean option state, except for the options that are "global". Global options
will retain their values and meaning even after --next. will retain their values and meaning even after --next.
The following options are global:
%GLOBALS.