From a562d544d8520a0f113ad1a348e28ea00f27b693 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 3 Oct 2012 16:37:06 -0400 Subject: When ‘--help’ is given, just run ‘man’ to show the manual page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- scripts/nix-build.in | 26 ++------------------------ scripts/nix-channel.in | 28 ++++++++-------------------- scripts/nix-collect-garbage.in | 2 ++ scripts/nix-copy-closure.in | 11 +++++++---- scripts/nix-install-package.in | 23 +++-------------------- scripts/nix-pull.in | 4 +++- scripts/nix-push.in | 17 +++-------------- 7 files changed, 28 insertions(+), 83 deletions(-) (limited to 'scripts') diff --git a/scripts/nix-build.in b/scripts/nix-build.in index 8973f5fb7316..427bc605b562 100755 --- a/scripts/nix-build.in +++ b/scripts/nix-build.in @@ -33,36 +33,14 @@ for (my $n = 0; $n < scalar @ARGV; $n++) { my $arg = $ARGV[$n]; if ($arg eq "--help") { - print STDERR < 2; + die "$0: `--add' requires one or two arguments\n" if scalar @ARGV < 1 || scalar @ARGV > 2; my $url = shift @ARGV; my $name = shift @ARGV; unless (defined $name) { @@ -185,13 +173,13 @@ while (scalar @ARGV) { } if ($arg eq "--remove") { - usageError if scalar @ARGV != 1; + die "$0: `--remove' requires one argument\n" if scalar @ARGV != 1; removeChannel(shift @ARGV); last; } if ($arg eq "--list") { - usageError if scalar @ARGV != 0; + die "$0: `--list' requires one argument\n" if scalar @ARGV != 0; readChannels; foreach my $name (keys %channels) { print "$name $channels{$name}\n"; @@ -205,7 +193,7 @@ while (scalar @ARGV) { } elsif ($arg eq "--help") { - usageError; + exec "man nix-channel" or die; } elsif ($arg eq "--version") { @@ -214,6 +202,6 @@ while (scalar @ARGV) { } else { - die "unknown argument `$arg'; try `--help'"; + die "unknown argument `$arg'; try `--help'\n"; } } diff --git a/scripts/nix-collect-garbage.in b/scripts/nix-collect-garbage.in index bd186022095c..28b0c749f125 100755 --- a/scripts/nix-collect-garbage.in +++ b/scripts/nix-collect-garbage.in @@ -16,6 +16,8 @@ for my $arg (@ARGV) { $removeOld = 1; } elsif ($arg eq "--dry-run") { $dryRun = 1; + } elsif ($arg eq "--help") { + exec "man nix-collect-garbage" or die; } else { push @args, $arg; } diff --git a/scripts/nix-copy-closure.in b/scripts/nix-copy-closure.in index 12a83cff979c..0eb7a4ed0c16 100755 --- a/scripts/nix-copy-closure.in +++ b/scripts/nix-copy-closure.in @@ -37,8 +37,11 @@ my @storePaths = (); while (@ARGV) { my $arg = shift @ARGV; - - if ($arg eq "--sign") { + + if ($arg eq "--help") { + exec "man nix-copy-closure" or die; + } + elsif ($arg eq "--sign") { $sign = 1; } elsif ($arg eq "--gzip") { @@ -92,7 +95,7 @@ else { # Copy FROM the remote machine. my $extraOpts = $includeOutputs ? "--include-outputs" : ""; my $pid = open(READ, "set -f; ssh @sshOpts $sshHost nix-store --query --requisites $extraOpts @storePaths|") or die; - + while () { chomp; die "bad: $_" unless /^\//; @@ -106,7 +109,7 @@ else { # Copy FROM the remote machine. print STDERR "copying ", scalar @missing, " missing paths from ‘$sshHost’...\n"; $compressor = "| $compressor" if $compressor ne ""; $decompressor = "$decompressor |" if $decompressor ne ""; - $progressViewer = "$progressViewer |" if $progressViewer ne ""; + $progressViewer = "$progressViewer |" if $progressViewer ne ""; unless ($dryRun) { my $extraOpts = $sign ? "--sign" : ""; system("set -f; ssh $sshHost @sshOpts 'nix-store --export $extraOpts @missing $compressor' | $progressViewer $decompressor $Nix::Config::binDir/nix-store --import > /dev/null") == 0 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 <