@matheusbsbs / matheus-bagliano / commits / 1b0baf1401
Fork 0

git-send-email: abort/usage on bad option

Instead of proceeding, abort and give usage message when a bad option is seen. Signed-off-by: Junio C Hamano <junkio@cox.net>

Michael Coleman committed Feb 27, 2007 at 22:47 UTC 1b0baf14014a2c98f1a03630294163447ce1976c
1 file changed +53 -44
git-send-email.perl
+53 -44
@@ -34,6 +34,53 @@ sub readline {
34 }
35 package main;
36
37 +
38 +sub usage {
39 + print <<EOT;
40 +git-send-email [options] <file | directory>...
41 +Options:
42 + --from Specify the "From:" line of the email to be sent.
43 +
44 + --to Specify the primary "To:" line of the email.
45 +
46 + --cc Specify an initial "Cc:" list for the entire series
47 + of emails.
48 +
49 + --bcc Specify a list of email addresses that should be Bcc:
50 + on all the emails.
51 +
52 + --compose Use \$EDITOR to edit an introductory message for the
53 + patch series.
54 +
55 + --subject Specify the initial "Subject:" line.
56 + Only necessary if --compose is also set. If --compose
57 + is not set, this will be prompted for.
58 +
59 + --in-reply-to Specify the first "In-Reply-To:" header line.
60 + Only used if --compose is also set. If --compose is not
61 + set, this will be prompted for.
62 +
63 + --chain-reply-to If set, the replies will all be to the previous
64 + email sent, rather than to the first email sent.
65 + Defaults to on.
66 +
67 + --no-signed-off-cc Suppress the automatic addition of email addresses
68 + that appear in a Signed-off-by: line, to the cc: list.
69 + Note: Using this option is not recommended.
70 +
71 + --smtp-server If set, specifies the outgoing SMTP server to use.
72 + Defaults to localhost.
73 +
74 + --suppress-from Suppress sending emails to yourself if your address
75 + appears in a From: line.
76 +
77 + --quiet Make git-send-email less verbose. One line per email
78 + should be all that is output.
79 +
80 +EOT
81 + exit(1);
82 +}
83 +
84 # most mail servers generate the Date: header, but not all...
85 sub format_2822_time {
86 my ($time) = @_;
@@ -120,6 +167,10 @@ my $rc = GetOptions("from=s" => \$from,
167 "dry-run" => \$dry_run,
168 );
169
170 +unless ($rc) {
171 + usage();
172 +}
173 +
174 # Verify the user input
175
176 foreach my $entry (@to) {
@@ -311,50 +362,8 @@ if (@files) {
362 print $_,"\n" for (@files);
363 }
364 } else {
314 - print <<EOT;
315 -git-send-email [options] <file | directory> [... file | directory ]
316 -Options:
317 - --from Specify the "From:" line of the email to be sent.
318 -
319 - --to Specify the primary "To:" line of the email.
320 -
321 - --cc Specify an initial "Cc:" list for the entire series
322 - of emails.
323 -
324 - --bcc Specify a list of email addresses that should be Bcc:
325 - on all the emails.
326 -
327 - --compose Use \$EDITOR to edit an introductory message for the
328 - patch series.
329 -
330 - --subject Specify the initial "Subject:" line.
331 - Only necessary if --compose is also set. If --compose
332 - is not set, this will be prompted for.
333 -
334 - --in-reply-to Specify the first "In-Reply-To:" header line.
335 - Only used if --compose is also set. If --compose is not
336 - set, this will be prompted for.
337 -
338 - --chain-reply-to If set, the replies will all be to the previous
339 - email sent, rather than to the first email sent.
340 - Defaults to on.
341 -
342 - --no-signed-off-cc Suppress the automatic addition of email addresses
343 - that appear in a Signed-off-by: line, to the cc: list.
344 - Note: Using this option is not recommended.
345 -
346 - --smtp-server If set, specifies the outgoing SMTP server to use.
347 - Defaults to localhost.
348 -
349 - --suppress-from Suppress sending emails to yourself if your address
350 - appears in a From: line.
351 -
352 - --quiet Make git-send-email less verbose. One line per email should be
353 - all that is output.
354 -
355 -Error: Please specify a file or a directory on the command line.
356 -EOT
357 - exit(1);
365 + print STDERR "\nNo patch files specified!\n\n";
366 + usage();
367 }
368
369 # Variables we set as part of the loop over files