cvsimport: Improve usage error reporting
Actually tell the user what he did wrong in case of usage errors instead of only printing the general usage information. Signed-off-by: Frank Lichtenheld <frank@lichtenheld.de> Signed-off-by: Junio C Hamano <junkio@cox.net>
Frank Lichtenheld committed
Apr 6, 2007 at 23:52 UTC
7bf77644e70d881f407c77e6d65ebe70c90916d6
1 file changed
+6
-4
git-cvsimport.perl
+6
-4
@@ -32,7 +32,9 @@ $ENV{'TZ'}="UTC";
32
our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a);
33
my (%conv_author_name, %conv_author_email);
34
35
-sub usage() {
35
+sub usage(;$) {
36
+ my $msg = shift;
37
+ print(STDERR "Error: $msg\n") if $msg;
38
print STDERR <<END;
39
Usage: ${\basename $0} # fetch/update GIT from CVS
40
[-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]
@@ -117,7 +119,7 @@ read_repo_config($opts);
119
getopts($opts) or usage();
120
usage if $opt_h;
121
120
-@ARGV <= 1 or usage();
122
+@ARGV <= 1 or usage("You can't specify more than one CVS module");
123
124
if ($opt_d) {
125
$ENV{"CVSROOT"} = $opt_d;
@@ -130,7 +132,7 @@ if ($opt_d) {
132
} elsif ($ENV{"CVSROOT"}) {
133
$opt_d = $ENV{"CVSROOT"};
134
} else {
133
- die "CVSROOT needs to be set";
135
+ usage("CVSROOT needs to be set");
136
}
137
$opt_o ||= "origin";
138
$opt_s ||= "-";
@@ -149,7 +151,7 @@ if ($#ARGV == 0) {
151
chomp $cvs_tree;
152
close $f;
153
} else {
152
- usage();
154
+ usage("CVS module has to be specified");
155
}
156
157
our @mergerx = ();