From: Ian Jackson Date: Sat, 25 Jul 2020 17:22:56 +0000 (+0100) Subject: Provide usage summary, invoked with -h --help X-Git-Tag: nailing-cargo/1.0.0~71 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=cd369ddf5b96a7f3a885b61c41f95d70832f2d3d;p=nailing-cargo.git Provide usage summary, invoked with -h --help Closes #7 Signed-off-by: Ian Jackson --- diff --git a/README.md b/README.md index eb516de..a2602a8 100644 --- a/README.md +++ b/README.md @@ -363,6 +363,8 @@ Options * `!locked`: cargo would reject `--locked`, so don't pass it. Hazardous. * `!offline`: the build command would reject `--offline`, so never pass it. *Not* overridden by configuration or command line. + * `-h` | `--help`: Print usage summary. + Environment of the build command -------------------------------- diff --git a/nailing-cargo b/nailing-cargo index 4a62eb8..806f7bd 100755 --- a/nailing-cargo +++ b/nailing-cargo @@ -1,6 +1,35 @@ #!/usr/bin/perl -w # nailing-cargo: wrapper to use unpublished local crates # SPDX-License-Identifier: AGPL-3.0-or-later +our $usage = <<'END'; + +usages: + + nailing-cargo [--] ... + nailing-cargo --- [--] ... + nailing-cargo --- [--] ... + +options: + + -v Increase verbosity. (Default is 1) + -q Set verbosity to 0 + -D Increase amount of debugging dump. + -n "No action": stop after writing Cargo.toml.nailing~ + everywhere, and do not run any build command + + -c Do add cargo command line options } default is add if + -C Do not add cargo command line options } command is cargo + + -o --online -O --offline + -u --cargo-lock-update -U --no-cargo-lock-update + + -T --target= Specify target architecture + -h --help Print this message + + -s Treat command as `cargo ` + --subcommand-props=,... Override command props (see docs) + +END our $self; @@ -68,6 +97,11 @@ our $verbose=1; our ($noact,$dump); our $target; +sub print_usage () { + print $usage or die $!; + exit 0; +} + sub read_or_enoent ($) { my ($fn) = @_; if (!open R, '<', $fn) { @@ -831,7 +865,9 @@ sub parse_args () { } if (m{^-[^-]}) { while (m{^-.}) { - if (s{^-v}{-}) { + if (s{^-h}{-}) { + print_usage(); + } elsif (s{^-v}{-}) { $verbose++; } elsif (s{^-q}{-}) { $verbose=0; @@ -854,6 +890,8 @@ sub parse_args () { $not_a_nailing_opt->(); } } + } elsif (s{^--help$}{}) { + print_usage(); } elsif (s{^--target=}{}) { $target = $_; } elsif (m{^--(on|off)line$}) {