2018-01-07 14:34:46 +08:00
|
|
|
#!/usr/bin/env perl
|
2020-03-23 21:44:29 +08:00
|
|
|
#***************************************************************************
|
|
|
|
# _ _ ____ _
|
|
|
|
# Project ___| | | | _ \| |
|
|
|
|
# / __| | | | |_) | |
|
|
|
|
# | (__| |_| | _ <| |___
|
|
|
|
# \___|\___/|_| \_\_____|
|
|
|
|
#
|
2023-01-02 20:51:48 +08:00
|
|
|
# Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# This software is licensed as described in the file COPYING, which
|
|
|
|
# you should have received as part of this distribution. The terms
|
2020-11-04 21:02:01 +08:00
|
|
|
# are also available at https://curl.se/docs/copyright.html.
|
2020-03-23 21:44:29 +08:00
|
|
|
#
|
|
|
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
# copies of the Software, and permit persons to whom the Software is
|
|
|
|
# furnished to do so, under the terms of the COPYING file.
|
|
|
|
#
|
|
|
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
# KIND, either express or implied.
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
#
|
2020-03-23 21:44:29 +08:00
|
|
|
###########################################################################
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2017-01-17 07:26:08 +08:00
|
|
|
=begin comment
|
|
|
|
|
|
|
|
This script generates the manpage.
|
|
|
|
|
2020-03-26 06:16:28 +08:00
|
|
|
Example: gen.pl <command> [files] > curl.1
|
2017-01-17 07:26:08 +08:00
|
|
|
|
|
|
|
Dev notes:
|
|
|
|
|
|
|
|
We open *input* files in :crlf translation (a no-op on many platforms) in
|
|
|
|
case we have CRLF line endings in Windows but a perl that defaults to LF.
|
|
|
|
Unfortunately it seems some perls like msysgit can't handle a global input-only
|
|
|
|
:crlf so it has to be specified on each file open for text input.
|
|
|
|
|
|
|
|
=end comment
|
|
|
|
=cut
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
my %optshort;
|
|
|
|
my %optlong;
|
2016-11-15 16:08:50 +08:00
|
|
|
my %helplong;
|
|
|
|
my %arglong;
|
2016-11-16 17:42:02 +08:00
|
|
|
my %redirlong;
|
2016-11-16 21:20:13 +08:00
|
|
|
my %protolong;
|
2020-07-13 20:15:04 +08:00
|
|
|
my %catlong;
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2021-09-27 22:47:04 +08:00
|
|
|
use POSIX qw(strftime);
|
2021-09-29 18:57:03 +08:00
|
|
|
my $date = strftime "%B %d %Y", localtime;
|
2021-09-28 23:36:09 +08:00
|
|
|
my $year = strftime "%Y", localtime;
|
2021-09-27 22:47:04 +08:00
|
|
|
my $version = "unknown";
|
|
|
|
|
|
|
|
open(INC, "<../../include/curl/curlver.h");
|
|
|
|
while(<INC>) {
|
|
|
|
if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
|
|
|
|
$version = $1;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(INC);
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
# get the long name version, return the man page string
|
|
|
|
sub manpageify {
|
|
|
|
my ($k)=@_;
|
|
|
|
my $l;
|
|
|
|
if($optlong{$k} ne "") {
|
|
|
|
# both short + long
|
|
|
|
$l = "\\fI-".$optlong{$k}.", --$k\\fP";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# only long
|
|
|
|
$l = "\\fI--$k\\fP";
|
|
|
|
}
|
|
|
|
return $l;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub printdesc {
|
|
|
|
my @desc = @_;
|
2021-11-15 21:47:46 +08:00
|
|
|
my $exam = 0;
|
2016-11-14 06:40:12 +08:00
|
|
|
for my $d (@desc) {
|
2021-09-28 16:30:59 +08:00
|
|
|
if($d =~ /\(Added in ([0-9.]+)\)/i) {
|
|
|
|
my $ver = $1;
|
|
|
|
if(too_old($ver)) {
|
|
|
|
$d =~ s/ *\(Added in $ver\)//gi;
|
|
|
|
}
|
|
|
|
}
|
2021-03-22 23:50:57 +08:00
|
|
|
if($d !~ /^.\\"/) {
|
|
|
|
# **bold**
|
|
|
|
$d =~ s/\*\*([^ ]*)\*\*/\\fB$1\\fP/g;
|
|
|
|
# *italics*
|
|
|
|
$d =~ s/\*([^ ]*)\*/\\fI$1\\fP/g;
|
|
|
|
}
|
2021-11-15 21:47:46 +08:00
|
|
|
if(!$exam && ($d =~ /^ /)) {
|
|
|
|
# start of example
|
|
|
|
$exam = 1;
|
|
|
|
print ".nf\n"; # no-fill
|
|
|
|
}
|
|
|
|
elsif($exam && ($d !~ /^ /)) {
|
|
|
|
# end of example
|
|
|
|
$exam = 0;
|
|
|
|
print ".fi\n"; # fill-in
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
# skip lines starting with space (examples)
|
2022-07-31 04:36:55 +08:00
|
|
|
if($d =~ /^[^ ]/ && $d =~ /--/) {
|
2022-11-14 06:58:47 +08:00
|
|
|
# scan for options in longest-names first order
|
|
|
|
for my $k (sort {length($b) <=> length($a)} keys %optlong) {
|
|
|
|
# --tlsv1 is complicated since --tlsv1.2 etc are also
|
|
|
|
# acceptable options!
|
|
|
|
if(($k eq "tlsv1") && ($d =~ /--tlsv1\.[0-9]\\f/)) {
|
|
|
|
next;
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
my $l = manpageify($k);
|
2022-11-14 06:58:47 +08:00
|
|
|
$d =~ s/\-\-$k([^a-z0-9-])/$l$1/g;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
}
|
2021-03-11 15:50:11 +08:00
|
|
|
# quote "bare" minuses in the output
|
|
|
|
$d =~ s/( |\\fI|^)--/$1\\-\\-/g;
|
|
|
|
$d =~ s/([ -]|\\fI|^)-/$1\\-/g;
|
2021-11-01 16:55:28 +08:00
|
|
|
# handle single quotes first on the line
|
2022-08-23 19:42:42 +08:00
|
|
|
$d =~ s/^(\s*)\'/$1\\(aq/;
|
|
|
|
# handle double quotes first on the line
|
|
|
|
$d =~ s/^(\s*)\"/$1\\(dq/;
|
2016-11-14 06:40:12 +08:00
|
|
|
print $d;
|
|
|
|
}
|
2022-01-05 23:35:34 +08:00
|
|
|
if($exam) {
|
|
|
|
print ".fi\n"; # fill-in
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
2016-11-16 18:41:02 +08:00
|
|
|
sub seealso {
|
|
|
|
my($standalone, $data)=@_;
|
|
|
|
if($standalone) {
|
|
|
|
return sprintf
|
|
|
|
".SH \"SEE ALSO\"\n$data\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "See also $data. ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub overrides {
|
|
|
|
my ($standalone, $data)=@_;
|
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"OVERRIDES\"\n$data\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub protocols {
|
|
|
|
my ($standalone, $data)=@_;
|
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"PROTOCOLS\"\n$data\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return "($data) ";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-09-28 16:30:59 +08:00
|
|
|
sub too_old {
|
|
|
|
my ($version)=@_;
|
2021-09-28 17:50:07 +08:00
|
|
|
my $a = 999999;
|
2021-09-28 16:30:59 +08:00
|
|
|
if($version =~ /^(\d+)\.(\d+)\.(\d+)/) {
|
2021-09-28 17:50:07 +08:00
|
|
|
$a = $1 * 1000 + $2 * 10 + $3;
|
|
|
|
}
|
|
|
|
elsif($version =~ /^(\d+)\.(\d+)/) {
|
|
|
|
$a = $1 * 1000 + $2 * 10;
|
|
|
|
}
|
|
|
|
if($a < 7300) {
|
|
|
|
# we consider everything before 7.30.0 to be too old to mention
|
|
|
|
# specific changes for
|
|
|
|
return 1;
|
2021-09-28 16:30:59 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-11-16 18:41:02 +08:00
|
|
|
sub added {
|
|
|
|
my ($standalone, $data)=@_;
|
2021-09-28 16:30:59 +08:00
|
|
|
if(too_old($data)) {
|
|
|
|
# don't mention ancient additions
|
|
|
|
return "";
|
|
|
|
}
|
2016-11-16 18:41:02 +08:00
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"ADDED\"\nAdded in curl version $data\n";
|
|
|
|
}
|
|
|
|
else {
|
2016-11-28 07:54:16 +08:00
|
|
|
return "Added in $data. ";
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
sub single {
|
2016-11-16 18:41:02 +08:00
|
|
|
my ($f, $standalone)=@_;
|
2020-03-26 06:16:28 +08:00
|
|
|
open(F, "<:crlf", "$f") ||
|
2016-11-16 18:41:02 +08:00
|
|
|
return 1;
|
2016-11-14 06:40:12 +08:00
|
|
|
my $short;
|
|
|
|
my $long;
|
|
|
|
my $tags;
|
|
|
|
my $added;
|
|
|
|
my $protocols;
|
|
|
|
my $arg;
|
|
|
|
my $mutexed;
|
|
|
|
my $requires;
|
2020-07-13 20:15:04 +08:00
|
|
|
my $category;
|
2016-11-14 06:40:12 +08:00
|
|
|
my $seealso;
|
2022-06-14 06:12:03 +08:00
|
|
|
my $copyright;
|
|
|
|
my $spdx;
|
2021-08-31 22:37:14 +08:00
|
|
|
my @examples; # there can be more than one
|
2016-11-14 06:40:12 +08:00
|
|
|
my $magic; # cmdline special option
|
2021-08-31 22:37:14 +08:00
|
|
|
my $line;
|
2022-10-18 16:39:43 +08:00
|
|
|
my $multi;
|
|
|
|
my $experimental;
|
2016-11-14 06:40:12 +08:00
|
|
|
while(<F>) {
|
2021-08-31 22:37:14 +08:00
|
|
|
$line++;
|
2016-11-16 21:20:13 +08:00
|
|
|
if(/^Short: *(.)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$short=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Long: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$long=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Added: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$added=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Tags: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$tags=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Arg: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$arg=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Magic: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$magic=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Mutexed: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$mutexed=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Protocols: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$protocols=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^See-also: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$seealso=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Requires: *(.*)/i) {
|
2016-11-14 06:40:12 +08:00
|
|
|
$requires=$1;
|
|
|
|
}
|
2020-07-13 20:15:04 +08:00
|
|
|
elsif(/^Category: *(.*)/i) {
|
|
|
|
$category=$1;
|
|
|
|
}
|
2021-08-31 22:37:14 +08:00
|
|
|
elsif(/^Example: *(.*)/i) {
|
|
|
|
push @examples, $1;
|
|
|
|
}
|
2022-10-18 16:39:43 +08:00
|
|
|
elsif(/^Multi: *(.*)/i) {
|
|
|
|
$multi=$1;
|
|
|
|
}
|
|
|
|
elsif(/^Experimental: yes/i) {
|
|
|
|
$experimental=1;
|
|
|
|
}
|
2022-06-14 06:12:03 +08:00
|
|
|
elsif(/^C: (.*)/i) {
|
|
|
|
$copyright=$1;
|
|
|
|
}
|
|
|
|
elsif(/^SPDX-License-Identifier: (.*)/i) {
|
|
|
|
$spdx=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Help: *(.*)/i) {
|
|
|
|
;
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
elsif(/^---/) {
|
2016-11-16 21:20:13 +08:00
|
|
|
if(!$long) {
|
2020-12-21 22:30:56 +08:00
|
|
|
print STDERR "ERROR: no 'Long:' in $f\n";
|
2021-11-15 22:58:20 +08:00
|
|
|
return 1;
|
2016-11-16 21:20:13 +08:00
|
|
|
}
|
2020-07-13 20:15:04 +08:00
|
|
|
if(!$category) {
|
2020-12-21 22:30:56 +08:00
|
|
|
print STDERR "ERROR: no 'Category:' in $f\n";
|
2021-11-15 22:58:20 +08:00
|
|
|
return 2;
|
2020-07-13 20:15:04 +08:00
|
|
|
}
|
2021-08-31 22:37:14 +08:00
|
|
|
if(!$examples[0]) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: no 'Example:' present\n";
|
2021-11-15 22:58:20 +08:00
|
|
|
return 2;
|
2021-08-31 22:37:14 +08:00
|
|
|
}
|
2021-09-28 17:50:07 +08:00
|
|
|
if(!$added) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: no 'Added:' version present\n";
|
2021-11-15 22:58:20 +08:00
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if(!$seealso) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: no 'See-also:' field present\n";
|
|
|
|
return 2;
|
2021-09-28 17:50:07 +08:00
|
|
|
}
|
2022-06-14 06:12:03 +08:00
|
|
|
if(!$copyright) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: no 'C:' field present\n";
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
if(!$spdx) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: no 'SPDX-License-Identifier:' field present\n";
|
|
|
|
return 2;
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
last;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
else {
|
|
|
|
chomp;
|
|
|
|
print STDERR "WARN: unrecognized line in $f, ignoring:\n:'$_';"
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2018-11-26 16:56:49 +08:00
|
|
|
my @desc;
|
2016-11-14 06:40:12 +08:00
|
|
|
while(<F>) {
|
|
|
|
push @desc, $_;
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
my $opt;
|
|
|
|
if(defined($short) && $long) {
|
|
|
|
$opt = "-$short, --$long";
|
|
|
|
}
|
|
|
|
elsif($short && !$long) {
|
|
|
|
$opt = "-$short";
|
|
|
|
}
|
|
|
|
elsif($long && !$short) {
|
|
|
|
$opt = "--$long";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($arg) {
|
|
|
|
$opt .= " $arg";
|
|
|
|
}
|
|
|
|
|
2021-03-11 15:50:11 +08:00
|
|
|
# quote "bare" minuses in opt
|
|
|
|
$opt =~ s/( |^)--/$1\\-\\-/g;
|
|
|
|
$opt =~ s/( |^)-/$1\\-/g;
|
2016-11-16 18:41:02 +08:00
|
|
|
if($standalone) {
|
|
|
|
print ".TH curl 1 \"30 Nov 2016\" \"curl 7.52.0\" \"curl manual\"\n";
|
|
|
|
print ".SH OPTION\n";
|
|
|
|
print "curl $opt\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print ".IP \"$opt\"\n";
|
|
|
|
}
|
2016-11-28 08:01:13 +08:00
|
|
|
if($protocols) {
|
|
|
|
print protocols($standalone, $protocols);
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if($standalone) {
|
|
|
|
print ".SH DESCRIPTION\n";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
2022-10-18 16:39:43 +08:00
|
|
|
if($experimental) {
|
|
|
|
print "**WARNING**: this option is experimental. Do not use in production.\n\n";
|
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
printdesc(@desc);
|
|
|
|
undef @desc;
|
|
|
|
|
2022-11-14 06:58:47 +08:00
|
|
|
my @extra;
|
2022-10-18 16:39:43 +08:00
|
|
|
if($multi eq "single") {
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra, "\nIf --$long is provided several times, the last set ".
|
2022-10-18 16:39:43 +08:00
|
|
|
"value will be used.\n";
|
|
|
|
}
|
|
|
|
elsif($multi eq "append") {
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra, "\n--$long can be used several times in a command line\n";
|
2022-10-18 16:39:43 +08:00
|
|
|
}
|
|
|
|
elsif($multi eq "boolean") {
|
|
|
|
my $rev = "no-$long";
|
|
|
|
# for options that start with "no-" the reverse is then without
|
|
|
|
# the no- prefix
|
|
|
|
if($long =~ /^no-/) {
|
|
|
|
$rev = $long;
|
|
|
|
$rev =~ s/^no-//;
|
|
|
|
}
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra,
|
|
|
|
"\nProviding --$long multiple times has no extra effect.\n".
|
2022-10-18 16:39:43 +08:00
|
|
|
"Disable it again with --$rev.\n";
|
|
|
|
}
|
|
|
|
elsif($multi eq "mutex") {
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra,
|
|
|
|
"\nProviding --$long multiple times has no extra effect.\n";
|
2022-10-18 16:39:43 +08:00
|
|
|
}
|
2023-02-13 22:33:13 +08:00
|
|
|
elsif($multi eq "custom") {
|
|
|
|
; # left for the text to describe
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "$f:$line:1:ERROR: unrecognized Multi: '$multi'\n";
|
|
|
|
return 2;
|
|
|
|
}
|
2022-10-18 16:39:43 +08:00
|
|
|
|
2022-11-14 06:58:47 +08:00
|
|
|
printdesc(@extra);
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
my @foot;
|
|
|
|
if($seealso) {
|
|
|
|
my @m=split(/ /, $seealso);
|
|
|
|
my $mstr;
|
2020-09-01 16:16:45 +08:00
|
|
|
my $and = 0;
|
|
|
|
my $num = scalar(@m);
|
|
|
|
if($num > 2) {
|
|
|
|
# use commas up to this point
|
|
|
|
$and = $num - 1;
|
|
|
|
}
|
|
|
|
my $i = 0;
|
2016-11-14 06:40:12 +08:00
|
|
|
for my $k (@m) {
|
2018-05-28 20:59:37 +08:00
|
|
|
if(!$helplong{$k}) {
|
2021-11-15 22:58:20 +08:00
|
|
|
print STDERR "$f:$line:1:WARN: see-also a non-existing option: $k\n";
|
2018-05-28 20:59:37 +08:00
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
my $l = manpageify($k);
|
2020-09-01 16:16:45 +08:00
|
|
|
my $sep = " and";
|
|
|
|
if($and && ($i < $and)) {
|
|
|
|
$sep = ",";
|
|
|
|
}
|
|
|
|
$mstr .= sprintf "%s$l", $mstr?"$sep ":"";
|
|
|
|
$i++;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2016-11-16 18:41:02 +08:00
|
|
|
push @foot, seealso($standalone, $mstr);
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
if($requires) {
|
|
|
|
my $l = manpageify($long);
|
|
|
|
push @foot, "$l requires that the underlying libcurl".
|
|
|
|
" was built to support $requires. ";
|
|
|
|
}
|
|
|
|
if($mutexed) {
|
|
|
|
my @m=split(/ /, $mutexed);
|
|
|
|
my $mstr;
|
|
|
|
for my $k (@m) {
|
2018-05-28 20:59:37 +08:00
|
|
|
if(!$helplong{$k}) {
|
|
|
|
print STDERR "WARN: $f mutexes a non-existing option: $k\n";
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
my $l = manpageify($k);
|
|
|
|
$mstr .= sprintf "%s$l", $mstr?" and ":"";
|
|
|
|
}
|
2022-04-17 17:21:15 +08:00
|
|
|
push @foot, overrides($standalone,
|
|
|
|
"This option is mutually exclusive to $mstr. ");
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2021-08-31 22:37:14 +08:00
|
|
|
if($examples[0]) {
|
|
|
|
my $s ="";
|
|
|
|
$s="s" if($examples[1]);
|
|
|
|
print "\nExample$s:\n.nf\n";
|
|
|
|
foreach my $e (@examples) {
|
|
|
|
$e =~ s!\$URL!https://example.com!g;
|
|
|
|
print " curl $e\n";
|
|
|
|
}
|
|
|
|
print ".fi\n";
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
if($added) {
|
2016-11-16 18:41:02 +08:00
|
|
|
push @foot, added($standalone, $added);
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
if($foot[0]) {
|
|
|
|
print "\n";
|
2016-12-18 01:14:01 +08:00
|
|
|
my $f = join("", @foot);
|
|
|
|
$f =~ s/ +\z//; # remove trailing space
|
|
|
|
print "$f\n";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2016-11-16 18:41:02 +08:00
|
|
|
return 0;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub getshortlong {
|
|
|
|
my ($f)=@_;
|
2020-03-26 06:16:28 +08:00
|
|
|
open(F, "<:crlf", "$f");
|
2016-11-14 06:40:12 +08:00
|
|
|
my $short;
|
|
|
|
my $long;
|
2016-11-15 16:08:50 +08:00
|
|
|
my $help;
|
|
|
|
my $arg;
|
2016-11-16 21:20:13 +08:00
|
|
|
my $protocols;
|
2020-07-13 20:15:04 +08:00
|
|
|
my $category;
|
2016-11-14 06:40:12 +08:00
|
|
|
while(<F>) {
|
|
|
|
if(/^Short: (.)/i) {
|
|
|
|
$short=$1;
|
|
|
|
}
|
|
|
|
elsif(/^Long: (.*)/i) {
|
|
|
|
$long=$1;
|
|
|
|
}
|
2016-11-15 16:08:50 +08:00
|
|
|
elsif(/^Help: (.*)/i) {
|
|
|
|
$help=$1;
|
|
|
|
}
|
|
|
|
elsif(/^Arg: (.*)/i) {
|
|
|
|
$arg=$1;
|
|
|
|
}
|
2016-11-16 21:20:13 +08:00
|
|
|
elsif(/^Protocols: (.*)/i) {
|
|
|
|
$protocols=$1;
|
|
|
|
}
|
2020-07-13 20:15:04 +08:00
|
|
|
elsif(/^Category: (.*)/i) {
|
|
|
|
$category=$1;
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
elsif(/^---/) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
if($short) {
|
|
|
|
$optshort{$short}=$long;
|
|
|
|
}
|
|
|
|
if($long) {
|
|
|
|
$optlong{$long}=$short;
|
2016-11-15 16:08:50 +08:00
|
|
|
$helplong{$long}=$help;
|
|
|
|
$arglong{$long}=$arg;
|
2016-11-16 21:20:13 +08:00
|
|
|
$protolong{$long}=$protocols;
|
2020-07-13 20:15:04 +08:00
|
|
|
$catlong{$long}=$category;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub indexoptions {
|
2020-03-26 06:16:28 +08:00
|
|
|
my (@files) = @_;
|
|
|
|
foreach my $f (@files) {
|
|
|
|
getshortlong($f);
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub header {
|
2016-11-16 18:41:02 +08:00
|
|
|
my ($f)=@_;
|
2020-03-26 06:16:28 +08:00
|
|
|
open(F, "<:crlf", "$f");
|
2016-11-14 06:40:12 +08:00
|
|
|
my @d;
|
|
|
|
while(<F>) {
|
2021-09-27 22:47:04 +08:00
|
|
|
s/%DATE/$date/g;
|
|
|
|
s/%VERSION/$version/g;
|
2016-11-14 06:40:12 +08:00
|
|
|
push @d, $_;
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
printdesc(@d);
|
|
|
|
}
|
|
|
|
|
2016-11-15 16:08:50 +08:00
|
|
|
sub listhelp {
|
2021-09-28 23:36:09 +08:00
|
|
|
print <<HEAD
|
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \\| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \\___|\\___/|_| \\_\\_____|
|
|
|
|
*
|
2023-01-02 20:51:48 +08:00
|
|
|
* Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
|
2021-09-28 23:36:09 +08:00
|
|
|
*
|
|
|
|
* This software is licensed as described in the file COPYING, which
|
|
|
|
* you should have received as part of this distribution. The terms
|
|
|
|
* are also available at https://curl.se/docs/copyright.html.
|
|
|
|
*
|
|
|
|
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
|
|
|
* copies of the Software, and permit persons to whom the Software is
|
|
|
|
* furnished to do so, under the terms of the COPYING file.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: curl
|
2022-05-17 17:16:50 +08:00
|
|
|
*
|
2021-09-28 23:36:09 +08:00
|
|
|
***************************************************************************/
|
|
|
|
#include "tool_setup.h"
|
|
|
|
#include "tool_help.h"
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DO NOT edit tool_listhelp.c manually.
|
|
|
|
* This source file is generated with the following command:
|
|
|
|
|
|
|
|
cd \$srcroot/docs/cmdline-opts
|
|
|
|
./gen.pl listhelp *.d > \$srcroot/src/tool_listhelp.c
|
|
|
|
*/
|
|
|
|
|
|
|
|
const struct helptxt helptext[] = {
|
|
|
|
HEAD
|
|
|
|
;
|
2016-11-15 16:08:50 +08:00
|
|
|
foreach my $f (sort keys %helplong) {
|
|
|
|
my $long = $f;
|
|
|
|
my $short = $optlong{$long};
|
2020-07-13 20:15:04 +08:00
|
|
|
my @categories = split ' ', $catlong{$long};
|
2022-10-31 11:23:59 +08:00
|
|
|
my $bitmask = ' ';
|
2016-11-15 16:08:50 +08:00
|
|
|
my $opt;
|
|
|
|
|
|
|
|
if(defined($short) && $long) {
|
|
|
|
$opt = "-$short, --$long";
|
|
|
|
}
|
|
|
|
elsif($long && !$short) {
|
|
|
|
$opt = " --$long";
|
|
|
|
}
|
2020-07-13 20:15:04 +08:00
|
|
|
for my $i (0 .. $#categories) {
|
|
|
|
$bitmask .= 'CURLHELP_' . uc $categories[$i];
|
|
|
|
# If not last element, append |
|
|
|
|
if($i < $#categories) {
|
|
|
|
$bitmask .= ' | ';
|
|
|
|
}
|
|
|
|
}
|
2022-10-31 11:23:59 +08:00
|
|
|
$bitmask =~ s/(?=.{76}).{1,76}\|/$&\n /g;
|
2016-11-15 16:08:50 +08:00
|
|
|
my $arg = $arglong{$long};
|
|
|
|
if($arg) {
|
|
|
|
$opt .= " $arg";
|
|
|
|
}
|
2017-05-09 05:30:29 +08:00
|
|
|
my $desc = $helplong{$f};
|
|
|
|
$desc =~ s/\"/\\\"/g; # escape double quotes
|
2016-11-15 16:08:50 +08:00
|
|
|
|
2022-10-31 11:23:59 +08:00
|
|
|
my $line = sprintf " {\"%s\",\n \"%s\",\n %s},\n", $opt, $desc, $bitmask;
|
2016-11-16 17:42:02 +08:00
|
|
|
|
2021-01-12 03:27:58 +08:00
|
|
|
if(length($opt) > 78) {
|
|
|
|
print STDERR "WARN: the --$long name is too long\n";
|
|
|
|
}
|
2021-01-12 15:12:13 +08:00
|
|
|
elsif(length($desc) > 78) {
|
2021-01-12 03:27:58 +08:00
|
|
|
print STDERR "WARN: the --$long description is too long\n";
|
2016-11-16 17:42:02 +08:00
|
|
|
}
|
|
|
|
print $line;
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
2021-09-28 23:36:09 +08:00
|
|
|
print <<FOOT
|
|
|
|
{ NULL, NULL, CURLHELP_HIDDEN }
|
|
|
|
};
|
|
|
|
FOOT
|
|
|
|
;
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
|
|
|
|
2020-07-13 20:15:04 +08:00
|
|
|
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";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 16:08:50 +08:00
|
|
|
sub mainpage {
|
2020-03-26 06:16:28 +08:00
|
|
|
my (@files) = @_;
|
2021-11-15 22:58:20 +08:00
|
|
|
my $ret;
|
2016-11-15 16:08:50 +08:00
|
|
|
# show the page header
|
2016-11-16 18:41:02 +08:00
|
|
|
header("page-header");
|
2016-11-15 16:08:50 +08:00
|
|
|
|
|
|
|
# output docs for all options
|
2020-03-26 06:16:28 +08:00
|
|
|
foreach my $f (sort @files) {
|
2021-11-15 22:58:20 +08:00
|
|
|
$ret += single($f, 0);
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
2016-11-28 07:54:16 +08:00
|
|
|
|
2023-02-13 22:33:13 +08:00
|
|
|
if(!$ret) {
|
|
|
|
header("page-footer");
|
|
|
|
}
|
2021-11-15 22:58:20 +08:00
|
|
|
exit $ret if($ret);
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub showonly {
|
|
|
|
my ($f) = @_;
|
|
|
|
if(single($f, 1)) {
|
|
|
|
print STDERR "$f: failed\n";
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-16 21:20:13 +08:00
|
|
|
sub showprotocols {
|
|
|
|
my %prots;
|
|
|
|
foreach my $f (keys %optlong) {
|
|
|
|
my @p = split(/ /, $protolong{$f});
|
|
|
|
for my $p (@p) {
|
|
|
|
$prots{$p}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for(sort keys %prots) {
|
|
|
|
printf "$_ (%d options)\n", $prots{$_};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-15 16:08:50 +08:00
|
|
|
sub getargs {
|
2020-03-26 06:16:28 +08:00
|
|
|
my ($f, @s) = @_;
|
|
|
|
if($f eq "mainpage") {
|
|
|
|
mainpage(@s);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif($f eq "listhelp") {
|
|
|
|
listhelp();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif($f eq "single") {
|
|
|
|
showonly($s[0]);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif($f eq "protos") {
|
|
|
|
showprotocols();
|
|
|
|
return;
|
|
|
|
}
|
2020-07-13 20:15:04 +08:00
|
|
|
elsif($f eq "listcats") {
|
|
|
|
listcats();
|
|
|
|
return;
|
|
|
|
}
|
2016-11-15 16:08:50 +08:00
|
|
|
|
2020-07-13 20:15:04 +08:00
|
|
|
print "Usage: gen.pl <mainpage/listhelp/single FILE/protos/listcats> [files]\n";
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
2020-03-26 06:16:28 +08:00
|
|
|
my $cmd = shift @ARGV;
|
|
|
|
my @files = @ARGV; # the rest are the files
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
# learn all existing options
|
2020-03-26 06:16:28 +08:00
|
|
|
indexoptions(@files);
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2020-03-26 06:16:28 +08:00
|
|
|
getargs($cmd, @files);
|