Commit 81e61cda authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

gen: support 'redirect'

... and warn for too long --help lines
parent 1ef1f10c
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -26,6 +26,7 @@ Each file has a set of meta-data and a body of text.
    Mutexed: (space separated list of options this overrides)
    Mutexed: (space separated list of options this overrides)
    Requires: (space separated list of features this option requires)
    Requires: (space separated list of features this option requires)
    See-also: (space separated list of related options)
    See-also: (space separated list of related options)
    Redirect: (option name to use instead)
    Help: (short text for the --help output for this option)
    Help: (short text for the --help output for this option)
    --- (end of meta-data)
    --- (end of meta-data)


+29 −14
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@ my %optshort;
my %optlong;
my %optlong;
my %helplong;
my %helplong;
my %arglong;
my %arglong;
my %redirlong;


# get the long name version, return the man page string
# get the long name version, return the man page string
sub manpageify {
sub manpageify {
@@ -51,6 +52,7 @@ sub single {
    my $arg;
    my $arg;
    my $mutexed;
    my $mutexed;
    my $requires;
    my $requires;
    my $redirect;
    my $seealso;
    my $seealso;
    my $magic; # cmdline special option
    my $magic; # cmdline special option
    while(<F>) {
    while(<F>) {
@@ -84,6 +86,9 @@ sub single {
        elsif(/^Requires: (.*)/i) {
        elsif(/^Requires: (.*)/i) {
            $requires=$1;
            $requires=$1;
        }
        }
        elsif(/^Redirect: (.*)/i) {
            $redirect=$1;
        }
        elsif(/^---/) {
        elsif(/^---/) {
            last;
            last;
        }
        }
@@ -109,6 +114,11 @@ sub single {
    }
    }


    print ".IP \"$opt\"\n";
    print ".IP \"$opt\"\n";
    if($redirect) {
        my $l = manpageify($redirect);
        print "Use $l instead!\n";
    }
    else {
        my $o;
        my $o;
        if($protocols) {
        if($protocols) {
            $o++;
            $o++;
@@ -122,8 +132,8 @@ sub single {
            $o++;
            $o++;
            print "[cmdline control] ";
            print "[cmdline control] ";
        }
        }

        print "\n" if($o);
        print "\n" if($o);
    }


    printdesc(@desc);
    printdesc(@desc);
    undef @desc;
    undef @desc;
@@ -231,7 +241,12 @@ sub listhelp {
            $opt .= " $arg";
            $opt .= " $arg";
        }
        }


        printf " %-19s %s\n", $opt, $helplong{$f};
        my $line = sprintf " %-19s %s\n", $opt, $helplong{$f};

        if(length($line) > 79) {
            print STDERR "WARN: the --$long line is too long\n";
        }
        print $line;
    }
    }
}
}