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-channel.in | 28 ++++++++-------------------- 1 file changed, 8 insertions(+), 20 deletions(-) (limited to 'scripts/nix-channel.in') diff --git a/scripts/nix-channel.in b/scripts/nix-channel.in index 61ac823eb1f6..7b292ee8cf64 100755 --- a/scripts/nix-channel.in +++ b/scripts/nix-channel.in @@ -74,7 +74,7 @@ sub removeChannel { writeChannels; system("$Nix::Config::binDir/nix-env --profile '$profile' -e '$name'") == 0 - or die "cannot remove channel `$name'"; + or die "cannot remove channel `$name'\n"; } @@ -125,7 +125,7 @@ sub update { my $fullURL = "$url/nixexprs.tar.bz2"; print STDERR "downloading Nix expressions from `$fullURL'...\n"; my ($hash, $path) = `PRINT_PATH=1 QUIET=1 $Nix::Config::binDir/nix-prefetch-url '$fullURL'`; - die "cannot fetch `$fullURL'" if $? != 0; + die "cannot fetch `$fullURL'\n" if $? != 0; chomp $path; # If the URL contains a version number, append it to the name @@ -153,26 +153,14 @@ sub update { } -sub usageError { - 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"; } } -- cgit 1.4.1