about summary refs log tree commit diff
path: root/scripts/nix-install-package.in
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·37-0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-10-03T20·40-0400
commita562d544d8520a0f113ad1a348e28ea00f27b693 (patch)
tree5e8d7200b8521aa54e2c8846ef7c31fd5dac737e /scripts/nix-install-package.in
parent9c41c66c5b877dbb529f6147b28384a57a591895 (diff)
When ‘--help’ is given, just run ‘man’ to show the manual page
I.e. do what git does.  I'm too lazy to keep the builtin help text up
to date :-)

Also add ‘--help’ to various commands that lacked it
(e.g. nix-collect-garbage).
Diffstat (limited to 'scripts/nix-install-package.in')
-rwxr-xr-xscripts/nix-install-package.in23
1 files changed, 3 insertions, 20 deletions
diff --git a/scripts/nix-install-package.in b/scripts/nix-install-package.in
index 6564529385d6..e45337bcc9e5 100755
--- a/scripts/nix-install-package.in
+++ b/scripts/nix-install-package.in
@@ -6,25 +6,8 @@ use Nix::Config;
 use Nix::Utils;
 
 
-sub usageError {
-    print STDERR <<EOF;
-Usage: nix-install-package (FILE | --url URL)
-
-Install a Nix Package (.nixpkg) either directly from FILE or by
-downloading it from URL.
-
-Flags:
-  --profile / -p LINK: install into the specified profile
-  --non-interactive: don't run inside a new terminal
-EOF
-    ; # '
-    exit 1;
-}
-
-
 # Parse the command line arguments.
 my @args = @ARGV;
-usageError if scalar @args == 0;
 
 my $source;
 my $fromURL = 0;
@@ -34,14 +17,14 @@ my $interactive = 1;
 while (scalar @args) {
     my $arg = shift @args;
     if ($arg eq "--help") {
-        usageError;
+        exec "man nix-install-package" or die;
     }
     elsif ($arg eq "--url") {
         $fromURL = 1;
     }
     elsif ($arg eq "--profile" || $arg eq "-p") {
         my $profile = shift @args;
-        usageError if !defined $profile;
+        die "$0: `--profile' requires an argument\n" if !defined $profile;
         push @extraNixEnvArgs, "-p", $profile;
     }
     elsif ($arg eq "--non-interactive") {
@@ -52,7 +35,7 @@ while (scalar @args) {
     }
 }
 
-usageError unless defined $source;
+die "$0: please specify a .nixpkg file or URL\n" unless defined $source;
 
 
 # Re-execute in a terminal, if necessary, so that if we're executed