summaryrefslogtreecommitdiff
path: root/docs/cmdline-opts/gen.pl
diff options
context:
space:
mode:
Diffstat (limited to 'docs/cmdline-opts/gen.pl')
-rwxr-xr-xdocs/cmdline-opts/gen.pl20
1 files changed, 20 insertions, 0 deletions
diff --git a/docs/cmdline-opts/gen.pl b/docs/cmdline-opts/gen.pl
index e651f029a..c058987d4 100755
--- a/docs/cmdline-opts/gen.pl
+++ b/docs/cmdline-opts/gen.pl
@@ -138,8 +138,11 @@ sub single {
my $requires;
my $category;
my $seealso;
+ my @examples; # there can be more than one
my $magic; # cmdline special option
+ my $line;
while(<F>) {
+ $line++;
if(/^Short: *(.)/i) {
$short=$1;
}
@@ -173,6 +176,9 @@ sub single {
elsif(/^Category: *(.*)/i) {
$category=$1;
}
+ elsif(/^Example: *(.*)/i) {
+ push @examples, $1;
+ }
elsif(/^Help: *(.*)/i) {
;
}
@@ -185,6 +191,10 @@ sub single {
print STDERR "ERROR: no 'Category:' in $f\n";
exit 2;
}
+ if(!$examples[0]) {
+ print STDERR "$f:$line:1:ERROR: no 'Example:' present\n";
+ exit 2;
+ }
last;
}
else {
@@ -276,6 +286,16 @@ sub single {
}
push @foot, overrides($standalone, "This option overrides $mstr. ");
}
+ 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";
+ }
if($added) {
push @foot, added($standalone, $added);
}