]> git.mjollnir.org Git - cil.git/commitdiff
Make 'cil am' use a --batch option rather than an additional arg (which looks like...
authorAndrew Chilton <andychilton@gmail.com>
Mon, 9 Nov 2009 04:19:38 +0000 (17:19 +1300)
committerAndrew Chilton <andychilton@gmail.com>
Mon, 9 Nov 2009 04:19:38 +0000 (17:19 +1300)
bin/cil
lib/CIL/Command/Am.pm

diff --git a/bin/cil b/bin/cil
index 12a4010b23c437ecd310e137dccb11a20552b2af..30f4e2b742988acf2f48861b497338da05fea559 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -59,6 +59,7 @@ my @IN_OPTS = (
     'is-closed',    # for 'summary', 'list'
     'is-mine',      # for 'summary', 'list'
     'mine',         # for 'add'
+    'batch',        # for 'am'
     'help',
     'version',
 );
@@ -71,6 +72,7 @@ my %BOOLEAN_ARGS = (
     'is-closed' => 1,
     'is-mine'   => 1,
     'mine'      => 1,
+    'batch'     => 1,
 );
 
 ## ----------------------------------------------------------------------------
@@ -164,7 +166,7 @@ Commands:
    comment ISSUE
    attach  ISSUE FILENAME
    extract ATTACHMENT [--filename=FILENAME]
-   am      EMAIL.TXT
+   am      EMAIL.TXT [--batch]
    track   ISSUE
    fsck
 
index 4f6d2dd7e00454bb26908641e975ca11653070a1..5b763ea62686ba23661be2df7e3d050cc743597b 100644 (file)
@@ -33,9 +33,7 @@ use base qw(CIL::Command);
 sub name { 'am' }
 
 sub run {
-    my ($self, $cil, undef, $email_filename, $noquestions) = @_;
-
-    $noquestions = 0 unless $noquestions eq 'yes';
+    my ($self, $cil, $args, $email_filename) = @_;
 
     unless ( -r $email_filename ) {
         CIL::Utils::fatal("couldn't load email '$email_filename'");
@@ -91,8 +89,8 @@ sub run {
             $issue = (values %issue)[0];
         }
         else {
-            if ($noquestions) {
-                CIL::Utils->fatal('Cannot add to an existing message when there are multiple options, in noninteractive mode!');
+            if ( $args->{batch} ) {
+                CIL::Utils->fatal('Cannot add to an existing message (in batch mode) when there are multiple matched messages!');
             }
             my $ans = CIL::Utils::ans('To which issue would you like to add this comment: ');
 
@@ -127,8 +125,8 @@ sub run {
 
         # then ask if the user would like to add it
         CIL::Utils->msg("Couldn't find any likely issues, so this might be a new one.");
-        if ($noquestions) {
-            CIL::Utils->msg('Running in non interactive mode, so just adding it as a new one without asking"!');
+        if ( $args->{batch} ) {
+            CIL::Utils->msg('Running in batch mode, so just adding mail as a new issue');
         } else {
             my $ans = CIL::Utils::ans('Would you like to add this message as an issue shown above (y/n): ');
             return unless $ans eq 'y';