chiark / gitweb /
Provide usage summary, invoked with -h --help
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 17:22:56 +0000 (18:22 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 25 Jul 2020 17:22:56 +0000 (18:22 +0100)
Closes #7

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
README.md
nailing-cargo

index eb516de7e3fd2cf743e0eb7eb083c53f7013a3c0..a2602a8217bea81d5406ca25da320b108c3b601e 100644 (file)
--- 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
 --------------------------------
 
index 4a62eb8fec07d02259097daa386ca7a0e322ebd1..806f7bde40e6ba4f6d360d256d17fb70c8a2a85c 100755 (executable)
@@ -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-opts> <cargo-opts> [--] <subcmd>...
+  nailing-cargo <nailing-opts> --- <cargo> <cargo-opts> [--] <subcmd>...
+  nailing-cargo <nailing-opts> --- [--] <build-command>...
+
+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<arch>  --target=<arch>       Specify target architecture
+  -h --help                       Print this message
+
+  -s<subcommand>                  Treat command as `cargo <subcommand>`
+  --subcommand-props=<prop>,...   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$}) {