From aad36777e80a8094d1e97656918faa6bba96fa51 Mon Sep 17 00:00:00 2001 From: Johannes 'josch' Schauer Date: Fri, 29 Nov 2019 08:45:08 +0100 Subject: [PATCH] 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. --- coverage.sh | 17 +++++++++++++++-- mmdebstrap | 12 ++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/coverage.sh b/coverage.sh index 2d22ceb..b3e4e65 100755 --- a/coverage.sh +++ b/coverage.sh @@ -52,7 +52,7 @@ if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then fi starttime= -total=109 +total=110 i=1 print_header() { @@ -233,7 +233,20 @@ cat << END > shared/test.sh #!/bin/sh set -eu 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 if [ "$HAVE_QEMU" = "yes" ]; then ./run_qemu.sh diff --git a/mmdebstrap b/mmdebstrap index 8b5ef5b..d4e105d 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -1852,7 +1852,8 @@ sub main() { my $logfile = undef; Getopt::Long::Configure ('default', 'bundling', 'auto_abbrev', 'ignore_case_always'); 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; }, 'components=s@' => \$options->{components}, 'variant=s' => \$options->{variant}, @@ -2756,7 +2757,14 @@ require a double dash and may be abbreviated to uniqueness. =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>