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.
|
|
|
|
|
2024-03-08 18:22:12 +08:00
|
|
|
Example: managen <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.
|
2023-08-22 23:40:39 +08:00
|
|
|
Unfortunately it seems some perls like msysgit cannot handle a global input-only
|
2017-01-17 07:26:08 +08:00
|
|
|
: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);
|
2023-10-08 18:31:57 +08:00
|
|
|
my @ts;
|
|
|
|
if (defined($ENV{SOURCE_DATE_EPOCH})) {
|
2024-03-31 07:59:55 +08:00
|
|
|
@ts = gmtime($ENV{SOURCE_DATE_EPOCH});
|
2023-10-08 18:31:57 +08:00
|
|
|
} else {
|
|
|
|
@ts = localtime;
|
|
|
|
}
|
2024-03-31 07:59:55 +08:00
|
|
|
my $date = strftime "%Y-%m-%d", @ts;
|
2023-10-08 18:31:57 +08:00
|
|
|
my $year = strftime "%Y", @ts;
|
2021-09-27 22:47:04 +08:00
|
|
|
my $version = "unknown";
|
2023-02-22 00:17:49 +08:00
|
|
|
my $globals;
|
2024-08-14 19:36:20 +08:00
|
|
|
my $error = 0;
|
2024-06-25 17:35:48 +08:00
|
|
|
my $indent = 4;
|
|
|
|
|
2024-07-18 06:11:28 +08:00
|
|
|
# get the long name version, return the manpage string
|
2016-11-14 06:40:12 +08:00
|
|
|
sub manpageify {
|
|
|
|
my ($k)=@_;
|
|
|
|
my $l;
|
2024-03-04 22:16:11 +08:00
|
|
|
my $trail;
|
|
|
|
# the matching pattern might include a trailing dot that cannot be part of
|
|
|
|
# the option name
|
|
|
|
if($k =~ s/\.$//) {
|
|
|
|
# cut off trailing dot
|
|
|
|
$trail = ".";
|
|
|
|
}
|
2023-08-11 23:01:34 +08:00
|
|
|
my $klong = $k;
|
|
|
|
# quote "bare" minuses in the long name
|
|
|
|
$klong =~ s/-/\\-/g;
|
2024-03-04 22:16:11 +08:00
|
|
|
if($optlong{$k}) {
|
2016-11-14 06:40:12 +08:00
|
|
|
# both short + long
|
2024-03-04 22:16:11 +08:00
|
|
|
$l = "\\fI-".$optlong{$k}.", \\-\\-$klong\\fP$trail";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
# only long
|
2024-03-04 22:16:11 +08:00
|
|
|
$l = "\\fI\\-\\-$klong\\fP$trail";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
return $l;
|
|
|
|
}
|
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
|
2024-06-25 17:35:48 +08:00
|
|
|
my $colwidth=79; # max number of columns
|
2024-03-05 00:22:17 +08:00
|
|
|
|
2024-06-25 19:37:51 +08:00
|
|
|
sub prefixline {
|
|
|
|
my ($num) = @_;
|
|
|
|
print "\t" x ($num/8);
|
|
|
|
print ' ' x ($num%8);
|
|
|
|
}
|
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
sub justline {
|
|
|
|
my ($lvl, @line) = @_;
|
|
|
|
my $w = -1;
|
|
|
|
my $spaces = -1;
|
2024-06-25 17:35:48 +08:00
|
|
|
my $width = $colwidth - ($lvl * $indent);
|
2024-03-05 00:22:17 +08:00
|
|
|
for(@line) {
|
|
|
|
$w += length($_);
|
|
|
|
$w++;
|
|
|
|
$spaces++;
|
|
|
|
}
|
|
|
|
my $inject = $width - $w;
|
|
|
|
my $ratio = 0; # stay at zero if no spaces at all
|
|
|
|
if($spaces) {
|
|
|
|
$ratio = $inject / $spaces;
|
|
|
|
}
|
|
|
|
my $spare = 0;
|
2024-06-25 19:37:51 +08:00
|
|
|
prefixline($lvl * $indent);
|
2024-03-05 00:22:17 +08:00
|
|
|
my $prev;
|
|
|
|
for(@line) {
|
|
|
|
while($spare >= 0.90) {
|
|
|
|
print " ";
|
|
|
|
$spare--;
|
|
|
|
}
|
|
|
|
printf "%s%s", $prev?" ":"", $_;
|
|
|
|
$prev = 1;
|
|
|
|
$spare += $ratio;
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub lastline {
|
|
|
|
my ($lvl, @line) = @_;
|
2024-08-14 19:36:20 +08:00
|
|
|
$line[0] =~ s/^( +)//;
|
|
|
|
prefixline($lvl * $indent + length($1));
|
2024-03-05 00:22:17 +08:00
|
|
|
my $prev = 0;
|
|
|
|
for(@line) {
|
|
|
|
printf "%s%s", $prev?" ":"", $_;
|
|
|
|
$prev = 1;
|
|
|
|
}
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
sub outputpara {
|
|
|
|
my ($lvl, $f) = @_;
|
|
|
|
$f =~ s/\n/ /g;
|
|
|
|
|
|
|
|
my $w = 0;
|
|
|
|
my @words = split(/ */, $f);
|
2024-06-25 17:35:48 +08:00
|
|
|
my $width = $colwidth - ($lvl * $indent);
|
2024-03-05 00:22:17 +08:00
|
|
|
|
|
|
|
my @line;
|
|
|
|
for my $e (@words) {
|
|
|
|
my $l = length($e);
|
|
|
|
my $spaces = scalar(@line);
|
|
|
|
if(($w + $l + $spaces) >= $width) {
|
|
|
|
justline($lvl, @line);
|
|
|
|
undef @line;
|
|
|
|
$w = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
push @line, $e;
|
|
|
|
$w += $l; # new width
|
|
|
|
}
|
|
|
|
if($w) {
|
|
|
|
lastline($lvl, @line);
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
sub printdesc {
|
2024-03-05 00:22:17 +08:00
|
|
|
my ($manpage, $baselvl, @desc) = @_;
|
|
|
|
|
|
|
|
if($manpage) {
|
|
|
|
for my $d (@desc) {
|
|
|
|
print $d;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my $p = -1;
|
|
|
|
my $para;
|
|
|
|
for my $l (@desc) {
|
|
|
|
my $lvl;
|
|
|
|
if($l !~ /^[\n\r]+/) {
|
|
|
|
# get the indent level off the string
|
|
|
|
$l =~ s/^\[([0-9q]*)\]//;
|
|
|
|
$lvl = $1;
|
|
|
|
}
|
|
|
|
if(($p =~ /q/) && ($lvl !~ /q/)) {
|
|
|
|
# the previous was quoted, this is not
|
|
|
|
print "\n";
|
|
|
|
}
|
|
|
|
if($lvl != $p) {
|
|
|
|
outputpara($baselvl + $p, $para);
|
|
|
|
$para = "";
|
|
|
|
}
|
|
|
|
if($lvl =~ /q/) {
|
|
|
|
# quoted, do not right-justify
|
|
|
|
chomp $l;
|
|
|
|
lastline($baselvl + $lvl + 1, $l);
|
2024-08-14 19:36:20 +08:00
|
|
|
my $w = ($baselvl + $lvl + 1) * $indent + length($l);
|
|
|
|
if ($w > $colwidth) {
|
|
|
|
print STDERR "ERROR: $w columns is too long\n";
|
|
|
|
print STDERR "$l\n";
|
|
|
|
$error++;
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$para .= $l;
|
|
|
|
}
|
|
|
|
|
|
|
|
$p = $lvl;
|
|
|
|
}
|
|
|
|
outputpara($baselvl + $p, $para);
|
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 {
|
2024-06-25 17:35:48 +08:00
|
|
|
return "See also $data. ";
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub overrides {
|
|
|
|
my ($standalone, $data)=@_;
|
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"OVERRIDES\"\n$data\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sub protocols {
|
2024-03-05 00:22:17 +08:00
|
|
|
my ($manpage, $standalone, $data)=@_;
|
2016-11-16 18:41:02 +08:00
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"PROTOCOLS\"\n$data\n";
|
|
|
|
}
|
|
|
|
else {
|
2024-03-12 15:45:22 +08:00
|
|
|
return "($data) " if($manpage);
|
2024-03-05 00:22:17 +08:00
|
|
|
return "[1]($data) " if(!$manpage);
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
2024-06-24 19:57:02 +08:00
|
|
|
if($a < 7600) {
|
|
|
|
# we consider everything before 7.60.0 to be too old to mention
|
2021-09-28 17:50:07 +08:00
|
|
|
# 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)) {
|
2023-08-22 23:40:39 +08:00
|
|
|
# do not mention ancient additions
|
2021-09-28 16:30:59 +08:00
|
|
|
return "";
|
|
|
|
}
|
2016-11-16 18:41:02 +08:00
|
|
|
if($standalone) {
|
|
|
|
return ".SH \"ADDED\"\nAdded in curl version $data\n";
|
|
|
|
}
|
|
|
|
else {
|
2024-06-25 17:35:48 +08:00
|
|
|
return "Added in $data. ";
|
2016-11-16 18:41:02 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
sub render {
|
2024-03-05 00:22:17 +08:00
|
|
|
my ($manpage, $fh, $f, $line) = @_;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my @desc;
|
|
|
|
my $tablemode = 0;
|
|
|
|
my $header = 0;
|
|
|
|
# if $top is TRUE, it means a top-level page and not a command line option
|
|
|
|
my $top = ($line == 1);
|
|
|
|
my $quote;
|
2024-03-05 00:22:17 +08:00
|
|
|
my $level;
|
2024-06-25 22:28:33 +08:00
|
|
|
my $finalblank;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$start = 0;
|
|
|
|
|
|
|
|
while(<$fh>) {
|
|
|
|
my $d = $_;
|
|
|
|
$line++;
|
2024-06-25 22:28:33 +08:00
|
|
|
$finalblank = ($d eq "\n");
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if($d =~ /^\.(SH|BR|IP|B)/) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: nroff instruction in input: \".$1\"\n";
|
|
|
|
return 4;
|
|
|
|
}
|
|
|
|
if(/^ *<!--/) {
|
|
|
|
# skip comments
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if((!$start) && ($_ =~ /^[\r\n]*\z/)) {
|
|
|
|
# skip leading blank lines
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
$start = 1;
|
|
|
|
if(/^# (.*)/) {
|
|
|
|
$header = 1;
|
|
|
|
if($top != 1) {
|
|
|
|
# ignored for command line options
|
|
|
|
$blankline++;
|
|
|
|
next;
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".SH $1\n" if($manpage);
|
|
|
|
push @desc, "[0]$1\n" if(!$manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif(/^###/) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: ### header is not supported\n";
|
|
|
|
exit 3;
|
|
|
|
}
|
|
|
|
elsif(/^## (.*)/) {
|
|
|
|
my $word = $1;
|
|
|
|
# if there are enclosing quotes, remove them first
|
|
|
|
$word =~ s/[\"\'](.*)[\"\']\z/$1/;
|
|
|
|
|
|
|
|
# remove backticks from headers
|
2024-07-02 05:35:58 +08:00
|
|
|
$word =~ s/\`//g;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
2024-07-18 06:11:28 +08:00
|
|
|
# if there is a space, it needs quotes for manpage
|
2024-03-05 00:22:17 +08:00
|
|
|
if(($word =~ / /) && $manpage) {
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$word = "\"$word\"";
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
$level = 1;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if($top == 1) {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".IP $word\n" if($manpage);
|
|
|
|
push @desc, "\n" if(!$manpage);
|
|
|
|
push @desc, "[1]$word\n" if(!$manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if(!$tablemode) {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".RS\n" if($manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$tablemode = 1;
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".IP $word\n" if($manpage);
|
|
|
|
push @desc, "\n" if(!$manpage);
|
|
|
|
push @desc, "[1]$word\n" if(!$manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
$header = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif(/^##/) {
|
|
|
|
if($top == 1) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: ## empty header top-level mode\n";
|
|
|
|
exit 3;
|
|
|
|
}
|
|
|
|
if($tablemode) {
|
|
|
|
# end of table
|
2024-06-26 16:47:16 +08:00
|
|
|
push @desc, ".RE\n.IP\n" if($manpage);
|
2024-03-05 00:22:17 +08:00
|
|
|
$tablemode = 0;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
$header = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif(/^\.(IP|RS|RE)/) {
|
|
|
|
my ($cmd) = ($1);
|
|
|
|
print STDERR "$f:$line:1:ERROR: $cmd detected, use ##-style\n";
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
elsif(/^[ \t]*\n/) {
|
|
|
|
# count and ignore blank lines
|
|
|
|
$blankline++;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
elsif($d =~ /^ (.*)/) {
|
|
|
|
my $word = $1;
|
2024-03-05 00:22:17 +08:00
|
|
|
if(!$quote && $manpage) {
|
2024-08-30 05:59:17 +08:00
|
|
|
push @desc, "\n" if($blankline);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
push @desc, ".nf\n";
|
2024-08-30 05:59:17 +08:00
|
|
|
$blankline = 0;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
$quote = 1;
|
|
|
|
$d = "$word\n";
|
|
|
|
}
|
|
|
|
elsif($quote && ($d !~ /^ (.*)/)) {
|
|
|
|
# end of quote
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".fi\n" if($manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$quote = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
$d =~ s/`%DATE`/$date/g;
|
|
|
|
$d =~ s/`%VERSION`/$version/g;
|
|
|
|
$d =~ s/`%GLOBALS`/$globals/g;
|
|
|
|
|
|
|
|
# convert backticks to double quotes
|
|
|
|
$d =~ s/\`/\"/g;
|
|
|
|
|
2024-06-24 19:57:02 +08:00
|
|
|
if($d =~ /\(added in(.*)/i) {
|
|
|
|
if(length($1) < 2) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: broken up added-in line:\n";
|
|
|
|
print STDERR "$f:$line:1:ERROR: $d";
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
again:
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if($d =~ /\(Added in ([0-9.]+)\)/i) {
|
|
|
|
my $ver = $1;
|
|
|
|
if(too_old($ver)) {
|
|
|
|
$d =~ s/ *\(Added in $ver\)//gi;
|
2024-06-24 19:57:02 +08:00
|
|
|
goto again;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-07 01:07:07 +08:00
|
|
|
if(!$quote) {
|
|
|
|
if($d =~ /^(.*) /) {
|
|
|
|
printf STDERR "$f:$line:%d:ERROR: 2 spaces detected\n",
|
|
|
|
length($1);
|
|
|
|
return 3;
|
|
|
|
}
|
|
|
|
elsif($d =~ /[^\\][\<\>]/) {
|
|
|
|
print STDERR "$f:$line:1:WARN: un-escaped < or > used\n";
|
|
|
|
return 3;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
2024-02-07 01:07:07 +08:00
|
|
|
# convert backslash-'<' or '> to just the second character
|
2024-02-23 19:52:09 +08:00
|
|
|
$d =~ s/\\([><])/$1/g;
|
|
|
|
# convert single backslash to double-backslash
|
2024-03-05 00:22:17 +08:00
|
|
|
$d =~ s/\\/\\\\/g if($manpage);
|
2024-02-23 19:52:09 +08:00
|
|
|
|
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
if($manpage) {
|
|
|
|
if(!$quote && $d =~ /--/) {
|
|
|
|
$d =~ s/--([a-z0-9.-]+)/manpageify($1)/ge;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
# quote minuses in the output
|
|
|
|
$d =~ s/([^\\])-/$1\\-/g;
|
|
|
|
# replace single quotes
|
|
|
|
$d =~ s/\'/\\(aq/g;
|
|
|
|
# handle double quotes or periods first on the line
|
|
|
|
$d =~ s/^([\.\"])/\\&$1/;
|
|
|
|
# **bold**
|
|
|
|
$d =~ s/\*\*(\S.*?)\*\*/\\fB$1\\fP/g;
|
|
|
|
# *italics*
|
|
|
|
$d =~ s/\*(\S.*?)\*/\\fI$1\\fP/g;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# **bold**
|
|
|
|
$d =~ s/\*\*(\S.*?)\*\*/$1/g;
|
|
|
|
# *italics*
|
|
|
|
$d =~ s/\*(\S.*?)\*/$1/g;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
# trim trailing spaces
|
|
|
|
$d =~ s/[ \t]+\z//;
|
|
|
|
push @desc, "\n" if($blankline && !$header);
|
|
|
|
$blankline = 0;
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, $d if($manpage);
|
|
|
|
my $qstr = $quote ? "q": "";
|
|
|
|
push @desc, "[".(1 + $level)."$qstr]$d" if(!$manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$header = 0;
|
|
|
|
|
|
|
|
}
|
2024-06-25 22:28:33 +08:00
|
|
|
if($finalblank) {
|
2024-06-25 19:23:37 +08:00
|
|
|
print STDERR "$f:$line:1:ERROR: trailing blank line\n";
|
|
|
|
exit 3;
|
|
|
|
}
|
2024-06-28 15:01:08 +08:00
|
|
|
if($quote) {
|
|
|
|
# don't leave the quote "hanging"
|
|
|
|
push @desc, ".fi\n" if($manpage);
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if($tablemode) {
|
|
|
|
# end of table
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, ".RE\n.IP\n" if($manpage);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
return @desc;
|
|
|
|
}
|
|
|
|
|
2024-08-14 19:36:20 +08:00
|
|
|
sub maybespace {
|
|
|
|
my ($string) = @_;
|
|
|
|
|
|
|
|
if(($string =~ /(.* )(.*)/) &&
|
|
|
|
(length($2) <= 20)) {
|
|
|
|
return $1;
|
|
|
|
}
|
|
|
|
if(($string =~ /(.*:)(.*)/) &&
|
|
|
|
(length($2) <= 20)) {
|
|
|
|
return $1;
|
|
|
|
}
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
sub single {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, $manpage, $f, $standalone)=@_;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $fh;
|
2024-04-05 00:00:33 +08:00
|
|
|
open($fh, "<:crlf", "$dir/$f") ||
|
|
|
|
die "could not find $dir/$f";
|
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;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +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;
|
2024-01-14 21:50:52 +08:00
|
|
|
my $dline;
|
2022-10-18 16:39:43 +08:00
|
|
|
my $multi;
|
2023-02-21 23:42:26 +08:00
|
|
|
my $scope;
|
2022-10-18 16:39:43 +08:00
|
|
|
my $experimental;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $start;
|
|
|
|
my $list; # identifies the list, 1 example, 2 see-also
|
|
|
|
while(<$fh>) {
|
2021-08-31 22:37:14 +08:00
|
|
|
$line++;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if(/^ *<!--/) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
if(!$start) {
|
|
|
|
if(/^---/) {
|
|
|
|
$start = 1;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
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;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
elsif(/^See-also: +(.+)/i) {
|
2023-04-11 17:15:33 +08:00
|
|
|
if($seealso) {
|
|
|
|
print STDERR "ERROR: duplicated See-also in $f\n";
|
|
|
|
return 1;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
push @seealso, $1;
|
|
|
|
}
|
|
|
|
elsif(/^See-also:/i) {
|
|
|
|
$list=2;
|
|
|
|
}
|
|
|
|
elsif(/^ *- (.*)/i && ($list == 2)) {
|
|
|
|
push @seealso, $1;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
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;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
elsif(/^Example: +(.+)/i) {
|
|
|
|
push @examples, $1;
|
|
|
|
}
|
|
|
|
elsif(/^Example:/i) {
|
|
|
|
# '1' is the example list
|
|
|
|
$list = 1;
|
|
|
|
}
|
|
|
|
elsif(/^ *- (.*)/i && ($list == 1)) {
|
2021-08-31 22:37:14 +08:00
|
|
|
push @examples, $1;
|
|
|
|
}
|
2022-10-18 16:39:43 +08:00
|
|
|
elsif(/^Multi: *(.*)/i) {
|
|
|
|
$multi=$1;
|
|
|
|
}
|
2023-02-21 23:42:26 +08:00
|
|
|
elsif(/^Scope: *(.*)/i) {
|
|
|
|
$scope=$1;
|
|
|
|
}
|
2022-10-18 16:39:43 +08:00
|
|
|
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(/^---/) {
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$start++;
|
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;
|
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if(!$seealso[0]) {
|
2021-11-15 22:58:20 +08:00
|
|
|
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;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
print STDERR "$f:$line:1:WARN: unrecognized line in $f, ignoring:\n:'$_';"
|
2016-11-16 21:20:13 +08:00
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
|
|
|
if($start < 2) {
|
|
|
|
print STDERR "$f:1:1:ERROR: no proper meta-data header\n";
|
|
|
|
return 2;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
my @desc = render($manpage, $fh, $f, $line);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
close($fh);
|
2024-01-09 17:20:48 +08:00
|
|
|
if($tablemode) {
|
|
|
|
# end of table
|
|
|
|
push @desc, ".RE\n.IP\n";
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
my $opt;
|
2023-08-11 23:01:34 +08:00
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
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
|
2024-03-05 00:22:17 +08:00
|
|
|
$opt =~ s/-/\\-/g if($manpage);
|
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";
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
elsif($manpage) {
|
2016-11-16 18:41:02 +08:00
|
|
|
print ".IP \"$opt\"\n";
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
else {
|
|
|
|
lastline(1, $opt);
|
|
|
|
}
|
|
|
|
my @leading;
|
2016-11-28 08:01:13 +08:00
|
|
|
if($protocols) {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @leading, protocols($manpage, $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) {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @leading, "**WARNING**: this option is experimental. Do not use in production.\n\n";
|
2022-10-18 16:39:43 +08:00
|
|
|
}
|
|
|
|
|
2024-03-05 00:22:17 +08:00
|
|
|
my $pre = $manpage ? "\n": "[1]";
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2023-02-21 23:42:26 +08:00
|
|
|
if($scope) {
|
2024-07-04 19:38:18 +08:00
|
|
|
if($category !~ /global/) {
|
|
|
|
print STDERR "$f:$line:1:ERROR: global scope option does not have global category\n";
|
|
|
|
return 2;
|
|
|
|
}
|
2023-02-21 23:42:26 +08:00
|
|
|
if($scope eq "global") {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @desc, "\n" if(!$manpage);
|
|
|
|
push @desc, "${pre}This option is global and does not need to be specified for each use of --next.\n";
|
2023-02-21 23:42:26 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
print STDERR "$f:$line:1:ERROR: unrecognized scope: '$scope'\n";
|
|
|
|
return 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-14 06:58:47 +08:00
|
|
|
my @extra;
|
2022-10-18 16:39:43 +08:00
|
|
|
if($multi eq "single") {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @extra, "${pre}If --$long is provided several times, the last set ".
|
2023-09-08 20:32:29 +08:00
|
|
|
"value is used.\n";
|
2022-10-18 16:39:43 +08:00
|
|
|
}
|
|
|
|
elsif($multi eq "append") {
|
2024-03-05 00:22:17 +08:00
|
|
|
push @extra, "${pre}--$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-//;
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
my $dashes = $manpage ? "\\-\\-" : "--";
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra,
|
2024-03-05 00:22:17 +08:00
|
|
|
"${pre}Providing --$long multiple times has no extra effect.\n".
|
|
|
|
"Disable it again with $dashes$rev.\n";
|
2022-10-18 16:39:43 +08:00
|
|
|
}
|
|
|
|
elsif($multi eq "mutex") {
|
2022-11-14 06:58:47 +08:00
|
|
|
push @extra,
|
2024-03-05 00:22:17 +08:00
|
|
|
"${pre}Providing --$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
|
|
|
|
}
|
2024-06-28 04:54:28 +08:00
|
|
|
elsif($multi eq "per-URL") {
|
|
|
|
push @extra,
|
2024-06-28 15:01:08 +08:00
|
|
|
"${pre}--$long is associated with a single URL. Use it once per URL ".
|
2024-06-28 04:54:28 +08:00
|
|
|
"when you use several URLs in a command line.\n";
|
|
|
|
}
|
2023-02-13 22:33:13 +08:00
|
|
|
else {
|
|
|
|
print STDERR "$f:$line:1:ERROR: unrecognized Multi: '$multi'\n";
|
|
|
|
return 2;
|
|
|
|
}
|
2022-10-18 16:39:43 +08:00
|
|
|
|
2024-06-28 15:01:08 +08:00
|
|
|
printdesc($manpage, 2, (@leading, @desc, @extra));
|
|
|
|
undef @desc;
|
2022-11-14 06:58:47 +08:00
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
my @foot;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
|
|
|
|
my $mstr;
|
|
|
|
my $and = 0;
|
|
|
|
my $num = scalar(@seealso);
|
|
|
|
if($num > 2) {
|
|
|
|
# use commas up to this point
|
|
|
|
$and = $num - 1;
|
|
|
|
}
|
|
|
|
my $i = 0;
|
|
|
|
for my $k (@seealso) {
|
|
|
|
if(!$helplong{$k}) {
|
|
|
|
print STDERR "$f:$line:1:WARN: see-also a non-existing option: $k\n";
|
2020-09-01 16:16:45 +08:00
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
my $l = $manpage ? manpageify($k) : "--$k";
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $sep = " and";
|
|
|
|
if($and && ($i < $and)) {
|
|
|
|
$sep = ",";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
$mstr .= sprintf "%s$l", $mstr?"$sep ":"";
|
|
|
|
$i++;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2023-02-21 23:42:26 +08:00
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
if($requires) {
|
2024-03-05 00:22:17 +08:00
|
|
|
my $l = $manpage ? manpageify($long) : "--$long";
|
2024-06-24 16:53:29 +08:00
|
|
|
push @foot, "$l requires that libcurl".
|
|
|
|
" is built to support $requires.\n";
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
if($mutexed) {
|
|
|
|
my @m=split(/ /, $mutexed);
|
|
|
|
my $mstr;
|
2024-06-24 16:53:29 +08:00
|
|
|
my $num = scalar(@m);
|
|
|
|
my $count;
|
2016-11-14 06:40:12 +08:00
|
|
|
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";
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
my $l = $manpage ? manpageify($k) : "--$k";
|
2024-06-24 16:53:29 +08:00
|
|
|
my $sep = ", ";
|
|
|
|
if($count == ($num -1)) {
|
|
|
|
$sep = " and ";
|
|
|
|
}
|
|
|
|
$mstr .= sprintf "%s$l", $mstr?$sep:"";
|
|
|
|
$count++;
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
2022-04-17 17:21:15 +08:00
|
|
|
push @foot, overrides($standalone,
|
2024-06-24 16:53:29 +08:00
|
|
|
"This option is mutually exclusive with $mstr.\n");
|
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]);
|
2024-03-05 00:22:17 +08:00
|
|
|
if($manpage) {
|
|
|
|
print "\nExample$s:\n";
|
|
|
|
print ".nf\n";
|
|
|
|
foreach my $e (@examples) {
|
|
|
|
$e =~ s!\$URL!https://example.com!g;
|
|
|
|
# convert single backslahes to doubles
|
|
|
|
$e =~ s/\\/\\\\/g;
|
2024-08-30 14:54:19 +08:00
|
|
|
print "curl $e\n";
|
2024-03-05 00:22:17 +08:00
|
|
|
}
|
|
|
|
print ".fi\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
my @ex;
|
|
|
|
push @ex, "[0q]Example$s:\n";
|
2024-08-14 19:36:20 +08:00
|
|
|
#
|
|
|
|
# long ASCII examples are wrapped. Preferably at the last space
|
|
|
|
# before the margin. Or at a colon. Otherwise it just cuts at the
|
|
|
|
# exact boundary.
|
|
|
|
#
|
2024-03-05 00:22:17 +08:00
|
|
|
foreach my $e (@examples) {
|
|
|
|
$e =~ s!\$URL!https://example.com!g;
|
2024-08-14 19:36:20 +08:00
|
|
|
my $maxwidth = 60; # plus the " curl " 18 col prefix
|
|
|
|
if(length($e) > $maxwidth) {
|
|
|
|
# a long example, shorten it
|
|
|
|
my $p = substr($e, 0, $maxwidth);
|
|
|
|
$p = maybespace($p);
|
|
|
|
push @ex, "[0q] curl ".$p."\\";
|
|
|
|
$e = substr($e, length($p));
|
|
|
|
do {
|
|
|
|
my $r = substr($e, 0, $maxwidth);
|
|
|
|
if(length($e) > $maxwidth) {
|
|
|
|
$r = maybespace($r);
|
|
|
|
}
|
|
|
|
my $slash ="";
|
|
|
|
$e = substr($e, length($r));
|
|
|
|
if(length($e) > 0) {
|
|
|
|
$slash = "\\";
|
|
|
|
}
|
|
|
|
|
|
|
|
push @ex, "[0q] $r$slash" if($r);
|
|
|
|
} while(length($e));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
push @ex, "[0q] curl $e\n";
|
|
|
|
}
|
2024-03-05 00:22:17 +08:00
|
|
|
}
|
|
|
|
printdesc($manpage, 2, @ex);
|
2021-08-31 22:37:14 +08:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
2024-06-24 16:53:29 +08:00
|
|
|
push @foot, seealso($standalone, $mstr);
|
2024-06-25 17:35:48 +08:00
|
|
|
|
|
|
|
print "\n";
|
|
|
|
my $f = join("", @foot);
|
|
|
|
if($manpage) {
|
|
|
|
$f =~ s/ +\z//; # remove trailing space
|
|
|
|
print "$f\n";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printdesc($manpage, 2, "[1]$f");
|
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 {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, $f)=@_;
|
|
|
|
$f =~ s/^.*\///;
|
|
|
|
open(F, "<:crlf", "$dir/$f") ||
|
|
|
|
die "could not find $dir/$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;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $start = 0;
|
2024-06-05 20:08:02 +08:00
|
|
|
my $line = 0;
|
2016-11-14 06:40:12 +08:00
|
|
|
while(<F>) {
|
2024-06-05 20:08:02 +08:00
|
|
|
$line++;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if(!$start) {
|
|
|
|
if(/^---/) {
|
|
|
|
$start = 1;
|
|
|
|
}
|
|
|
|
next;
|
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
if(/^Short: (.)/i) {
|
|
|
|
$short=$1;
|
|
|
|
}
|
|
|
|
elsif(/^Long: (.*)/i) {
|
|
|
|
$long=$1;
|
|
|
|
}
|
2016-11-15 16:08:50 +08:00
|
|
|
elsif(/^Help: (.*)/i) {
|
|
|
|
$help=$1;
|
2024-06-05 20:08:02 +08:00
|
|
|
my $len = length($help);
|
|
|
|
if($len >= 49) {
|
|
|
|
printf STDERR "$f:$line:1:WARN: oversized help text: %d characters\n",
|
|
|
|
$len;
|
|
|
|
}
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
|
|
|
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 {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, @files) = @_;
|
2020-03-26 06:16:28 +08:00
|
|
|
foreach my $f (@files) {
|
2024-04-05 00:00:33 +08:00
|
|
|
getshortlong($dir, $f);
|
2020-03-26 06:16:28 +08:00
|
|
|
}
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub header {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, $manpage, $f)=@_;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $fh;
|
2024-04-05 00:00:33 +08:00
|
|
|
open($fh, "<:crlf", "$dir/$f") ||
|
|
|
|
die "could not find $dir/$f";
|
2024-03-05 00:22:17 +08:00
|
|
|
my @d = render($manpage, $fh, $f, 1);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
close($fh);
|
2024-03-05 00:22:17 +08:00
|
|
|
printdesc($manpage, 0, @d);
|
2016-11-14 06:40:12 +08:00
|
|
|
}
|
|
|
|
|
2024-07-04 19:38:18 +08:00
|
|
|
|
|
|
|
sub sourcecategories {
|
|
|
|
my ($dir) = @_;
|
|
|
|
my %cats;
|
|
|
|
open(H, "<$dir/../../src/tool_help.h") ||
|
|
|
|
die "can't find the header file";
|
|
|
|
while(<H>) {
|
|
|
|
if(/^\#define CURLHELP_([A-Z0-9]*)/) {
|
|
|
|
$cats{lc($1)}++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(H);
|
|
|
|
return %cats;
|
|
|
|
}
|
|
|
|
|
2016-11-15 16:08:50 +08:00
|
|
|
sub listhelp {
|
2024-07-04 19:38:18 +08:00
|
|
|
my ($dir) = @_;
|
|
|
|
my %cats = sourcecategories($dir);
|
|
|
|
|
2021-09-28 23:36:09 +08:00
|
|
|
print <<HEAD
|
|
|
|
/***************************************************************************
|
|
|
|
* _ _ ____ _
|
|
|
|
* Project ___| | | | _ \\| |
|
|
|
|
* / __| | | | |_) | |
|
|
|
|
* | (__| |_| | _ <| |___
|
|
|
|
* \\___|\\___/|_| \\_\\_____|
|
|
|
|
*
|
2023-02-22 00:17:49 +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.
|
2024-01-25 18:14:29 +08:00
|
|
|
* This source file is generated with the following command in an autotools
|
|
|
|
* build:
|
|
|
|
*
|
|
|
|
* "make listhelp"
|
2021-09-28 23:36:09 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
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) {
|
2024-07-04 19:38:18 +08:00
|
|
|
if(!$cats{ $categories[$i] }) {
|
|
|
|
printf STDERR "$f.md:ERROR: Unknown category '%s'\n",
|
|
|
|
$categories[$i];
|
|
|
|
exit 3;
|
|
|
|
}
|
|
|
|
|
2020-07-13 20:15:04 +08:00
|
|
|
$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
|
2024-07-04 19:38:18 +08:00
|
|
|
{ NULL, NULL, 0 }
|
2021-09-28 23:36:09 +08:00
|
|
|
};
|
|
|
|
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;
|
|
|
|
for my $i (0..$#categories) {
|
2024-07-04 19:38:18 +08:00
|
|
|
printf("#define CURLHELP_%-10s (%s)\n",
|
|
|
|
uc($categories[$i]), "1u << ${i}u");
|
2020-07-13 20:15:04 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-02-22 00:17:49 +08:00
|
|
|
sub listglobals {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, @files) = @_;
|
2023-02-22 00:17:49 +08:00
|
|
|
my @globalopts;
|
|
|
|
|
|
|
|
# Find all global options and output them
|
|
|
|
foreach my $f (sort @files) {
|
2024-04-05 00:00:33 +08:00
|
|
|
open(F, "<:crlf", "$dir/$f") ||
|
|
|
|
die "could not read $dir/$f";
|
2023-02-22 00:17:49 +08:00
|
|
|
my $long;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $start = 0;
|
2023-02-22 00:17:49 +08:00
|
|
|
while(<F>) {
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
if(/^---/) {
|
|
|
|
if(!$start) {
|
|
|
|
$start = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
2023-02-22 00:17:49 +08:00
|
|
|
if(/^Long: *(.*)/i) {
|
|
|
|
$long=$1;
|
|
|
|
}
|
|
|
|
elsif(/^Scope: global/i) {
|
|
|
|
push @globalopts, $long;
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
close(F);
|
|
|
|
}
|
|
|
|
return $ret if($ret);
|
|
|
|
for my $e (0 .. $#globalopts) {
|
|
|
|
$globals .= sprintf "%s--%s", $e?($globalopts[$e+1] ? ", " : " and "):"",
|
|
|
|
$globalopts[$e],;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-12-10 07:05:04 +08:00
|
|
|
sub noext {
|
|
|
|
my $in = $_[0];
|
2024-05-09 05:50:55 +08:00
|
|
|
$in =~ s/\.md//;
|
2023-12-10 07:05:04 +08:00
|
|
|
return $in;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sortnames {
|
|
|
|
return noext($a) cmp noext($b);
|
|
|
|
}
|
|
|
|
|
2016-11-15 16:08:50 +08:00
|
|
|
sub mainpage {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, $manpage, @files) = @_;
|
2024-03-05 00:22:17 +08:00
|
|
|
# $manpage is 1 for nroff, 0 for ASCII
|
2021-11-15 22:58:20 +08:00
|
|
|
my $ret;
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
my $fh;
|
2024-04-05 00:00:33 +08:00
|
|
|
open($fh, "<:crlf", "$dir/mainpage.idx") ||
|
|
|
|
die "no $dir/mainpage.idx file";
|
2016-11-15 16:08:50 +08:00
|
|
|
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
print <<HEADER
|
|
|
|
.\\" **************************************************************************
|
|
|
|
.\\" * _ _ ____ _
|
|
|
|
.\\" * Project ___| | | | _ \\| |
|
|
|
|
.\\" * / __| | | | |_) | |
|
|
|
|
.\\" * | (__| |_| | _ <| |___
|
|
|
|
.\\" * \\___|\\___/|_| \\_\\_____|
|
|
|
|
.\\" *
|
|
|
|
.\\" * Copyright (C) Daniel Stenberg, <daniel\@haxx.se>, et al.
|
|
|
|
.\\" *
|
|
|
|
.\\" * 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
|
|
|
|
.\\" *
|
|
|
|
.\\" **************************************************************************
|
|
|
|
.\\"
|
2024-07-18 06:11:28 +08:00
|
|
|
.\\" DO NOT EDIT. Generated by the curl project managen manpage generator.
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
.\\"
|
|
|
|
.TH curl 1 "$date" "curl $version" "curl Manual"
|
|
|
|
HEADER
|
2024-03-05 00:22:17 +08:00
|
|
|
if ($manpage);
|
2016-11-28 07:54:16 +08:00
|
|
|
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
while(<$fh>) {
|
|
|
|
my $f = $_;
|
|
|
|
chomp $f;
|
|
|
|
if($f =~ /^#/) {
|
2024-03-01 03:55:28 +08:00
|
|
|
# standard comment
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
if(/^%options/) {
|
|
|
|
# output docs for all options
|
|
|
|
foreach my $f (sort sortnames @files) {
|
2024-04-05 00:00:33 +08:00
|
|
|
$ret += single($dir, $manpage, $f, 0);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
# render the file
|
2024-04-05 00:00:33 +08:00
|
|
|
header($dir, $manpage, $f);
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
}
|
2023-02-13 22:33:13 +08:00
|
|
|
}
|
docs/cmdline: change to .md for cmdline docs
- switch all invidual files documenting command line options into .md,
as the documentation is now markdown-looking.
- made the parser treat 4-space indents as quotes
- switch to building the curl.1 manpage using the "mainpage.idx" file,
which lists the files to include to generate it, instead of using the
previous page-footer/headers. Also, those files are now also .md
ones, using the same format. I gave them underscore prefixes to make
them sort separately:
_NAME.md, _SYNOPSIS.md, _DESCRIPTION.md, _URL.md, _GLOBBING.md,
_VARIABLES.md, _OUTPUT.md, _PROTOCOLS.md, _PROGRESS.md, _VERSION.md,
_OPTIONS.md, _FILES.md, _ENVIRONMENT.md, _PROXYPREFIX.md,
_EXITCODES.md, _BUGS.md, _AUTHORS.md, _WWW.md, _SEEALSO.md
- updated test cases accordingly
Closes #12751
2024-01-21 06:18:43 +08:00
|
|
|
close($fh);
|
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 {
|
2024-04-05 00:00:33 +08:00
|
|
|
my ($dir, $f, @s) = @_;
|
2020-03-26 06:16:28 +08:00
|
|
|
if($f eq "mainpage") {
|
2024-04-05 00:00:33 +08:00
|
|
|
listglobals($dir, @s);
|
|
|
|
mainpage($dir, 1, @s);
|
2024-03-05 00:22:17 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif($f eq "ascii") {
|
2024-04-05 00:00:33 +08:00
|
|
|
listglobals($dir, @s);
|
|
|
|
mainpage($dir, 0, @s);
|
2020-03-26 06:16:28 +08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
elsif($f eq "listhelp") {
|
2024-07-04 19:38:18 +08:00
|
|
|
listhelp($dir);
|
2020-03-26 06:16:28 +08:00
|
|
|
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
|
|
|
|
2024-04-05 00:00:33 +08:00
|
|
|
print "Usage: managen ".
|
|
|
|
"[-d dir] <mainpage/ascii/listhelp/single FILE/protos/listcats> [files]\n";
|
2016-11-15 16:08:50 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
#------------------------------------------------------------------------
|
|
|
|
|
2024-04-05 00:00:33 +08:00
|
|
|
my $dir = ".";
|
|
|
|
my $include = "../../include";
|
2020-03-26 06:16:28 +08:00
|
|
|
my $cmd = shift @ARGV;
|
2024-04-05 00:00:33 +08:00
|
|
|
|
|
|
|
check:
|
|
|
|
if($cmd eq "-d") {
|
|
|
|
# specifies source directory
|
|
|
|
$dir = shift @ARGV;
|
|
|
|
$cmd = shift @ARGV;
|
|
|
|
goto check;
|
|
|
|
}
|
|
|
|
elsif($cmd eq "-I") {
|
|
|
|
# include path root
|
|
|
|
$include = shift @ARGV;
|
|
|
|
$cmd = shift @ARGV;
|
|
|
|
goto check;
|
|
|
|
}
|
2024-07-28 06:36:09 +08:00
|
|
|
elsif($cmd eq "-c") {
|
|
|
|
# Column width
|
|
|
|
$colwidth = 0 + shift @ARGV;
|
|
|
|
$cmd = shift @ARGV;
|
|
|
|
goto check;
|
|
|
|
}
|
2024-04-05 00:00:33 +08:00
|
|
|
|
2020-03-26 06:16:28 +08:00
|
|
|
my @files = @ARGV; # the rest are the files
|
|
|
|
|
2024-09-27 07:16:38 +08:00
|
|
|
# can be overridden for releases
|
2024-08-01 19:51:43 +08:00
|
|
|
if($ENV{'CURL_MAKETGZ_VERSION'}) {
|
|
|
|
$version = $ENV{'CURL_MAKETGZ_VERSION'};
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
open(INC, "<$include/curl/curlver.h");
|
|
|
|
while(<INC>) {
|
|
|
|
if($_ =~ /^#define LIBCURL_VERSION \"([0-9.]*)/) {
|
|
|
|
$version = $1;
|
|
|
|
last;
|
|
|
|
}
|
2024-04-05 00:00:33 +08:00
|
|
|
}
|
2024-08-01 19:51:43 +08:00
|
|
|
close(INC);
|
2024-04-05 00:00:33 +08:00
|
|
|
}
|
|
|
|
|
2016-11-14 06:40:12 +08:00
|
|
|
# learn all existing options
|
2024-04-05 00:00:33 +08:00
|
|
|
indexoptions($dir, @files);
|
2016-11-14 06:40:12 +08:00
|
|
|
|
2024-04-05 00:00:33 +08:00
|
|
|
getargs($dir, $cmd, @files);
|
2024-08-14 19:36:20 +08:00
|
|
|
|
|
|
|
exit $error;
|