add --man option and reduce output of --help option

Printing the full man page requires the perl-doc package. To avoid this
dependency, print the less verbose output containing only the synopsis
and the option list for the --help option and print the full output
(requiring perldoc) for the --man option.
This commit is contained in:
Johannes 'josch' Schauer 2019-11-29 08:45:08 +01:00
parent de8b6a457d
commit aad36777e8
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
2 changed files with 25 additions and 4 deletions

View file

@ -52,7 +52,7 @@ if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then
fi fi
starttime= starttime=
total=109 total=110
i=1 i=1
print_header() { print_header() {
@ -233,7 +233,20 @@ cat << END > shared/test.sh
#!/bin/sh #!/bin/sh
set -eu set -eu
export LC_ALL=C.UTF-8 export LC_ALL=C.UTF-8
$CMD --help | grep --quiet SYNOPSIS $CMD --help | grep --quiet --fixed-strings 'mmdebstrap [OPTION...] [SUITE [TARGET [MIRROR...]]]'
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
else
./run_null.sh SUDO
fi
print_header "test --man"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
$CMD --man | grep --quiet --fixed-strings 'mmdebstrap [OPTION...] [*SUITE* [*TARGET* [*MIRROR*...]]]'
END END
if [ "$HAVE_QEMU" = "yes" ]; then if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh ./run_qemu.sh

View file

@ -1852,7 +1852,8 @@ sub main() {
my $logfile = undef; my $logfile = undef;
Getopt::Long::Configure ('default', 'bundling', 'auto_abbrev', 'ignore_case_always'); Getopt::Long::Configure ('default', 'bundling', 'auto_abbrev', 'ignore_case_always');
GetOptions( GetOptions(
'h|help' => sub { pod2usage(-exitval => 0, -verbose => 2) }, 'h|help' => sub { pod2usage(-exitval => 0, -verbose => 1) },
'man' => sub { pod2usage(-exitval => 0, -verbose => 2) },
'version' => sub { print STDOUT "mmdebstrap $VERSION\n"; exit 0; }, 'version' => sub { print STDOUT "mmdebstrap $VERSION\n"; exit 0; },
'components=s@' => \$options->{components}, 'components=s@' => \$options->{components},
'variant=s' => \$options->{variant}, 'variant=s' => \$options->{variant},
@ -2756,7 +2757,14 @@ require a double dash and may be abbreviated to uniqueness.
=item B<-h,--help> =item B<-h,--help>
Print this help text and exit. Print synopsis and options of this man page and exit.
=item B<--man>
Show the full man page as generated from Perl POD in a pager. This requires
the perldoc program from the perl-doc package. This is the same as running:
pod2man /usr/bin/mmdebstrap | man -l -
=item B<--version> =item B<--version>