From: Ian Jackson Date: Sat, 25 Jul 2020 17:43:34 +0000 (+0100) Subject: Option --man[ual] to show the manual X-Git-Tag: nailing-cargo/1.0.0~69 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=03da2144985c5d4b6a82091b9987eff3f2ca6140;p=nailing-cargo.git Option --man[ual] to show the manual Closes #8 Signed-off-by: Ian Jackson --- diff --git a/README.md b/README.md index a2602a8..b1946b0 100644 --- a/README.md +++ b/README.md @@ -365,6 +365,9 @@ Options * `-h` | `--help`: Print usage summary. + * `--man` | `--manual`: Format this manual into html using `pandoc` + and display it with `w3m`. + Environment of the build command -------------------------------- diff --git a/nailing-cargo b/nailing-cargo index 22d5dd5..98436be 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -25,6 +25,7 @@ options: -T --target= Specify target architecture -h --help Print this message + --man --manual Display complete manual (in w3m) -s Treat command as `cargo ` --subcommand-props=,... Override command props (see docs) @@ -105,6 +106,13 @@ sub print_usage () { exit 0; } +sub show_manual () { + my $manual = ($base_path // '.').'/README.md'; + stat $manual or die "$self: manual not found at $manual: $!\n";; + exec 'sh','-ec', 'pandoc -- "$1" 2>&1 | w3m -T text/html', '--', $manual; + die "$self: exec sh failed: $!"; +} + sub read_or_enoent ($) { my ($fn) = @_; if (!open R, '<', $fn) { @@ -895,6 +903,8 @@ sub parse_args () { } } elsif (s{^--help$}{}) { print_usage(); + } elsif (s{^--man(?:ual)?$}{}) { + show_manual(); } elsif (s{^--target=}{}) { $target = $_; } elsif (m{^--(on|off)line$}) {