]> git.mjollnir.org Git - cil.git/commitdiff
Added a non interactive mode to cil am for when piping from mutt, for eg
authorPenny Leach <penny@mjollnir.org>
Tue, 21 Jul 2009 09:34:38 +0000 (11:34 +0200)
committerPenny Leach <penny@mjollnir.org>
Tue, 21 Jul 2009 09:34:38 +0000 (11:34 +0200)
lib/CIL/Command/Am.pm

index 02b96e60334aa9d059c87130fd86b929d01699db..bff0531412b7c2c749470d28971f1a498754b5a9 100644 (file)
@@ -33,8 +33,9 @@ use base qw(CIL::Command);
 sub name { 'am' }
 
 sub run {
-    my ($self, $cil, undef, $email_filename) = @_;
+    my ($self, $cil, undef, $email_filename, $noquestions) = @_;
 
+    $noquestions = 0 unless $noquestions eq 'yes';
 
     unless ( -r $email_filename ) {
         CIL::Utils::fatal("couldn't load email '$email_filename'");
@@ -90,6 +91,9 @@ 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!');
+            }
             my $ans = CIL::Utils::ans('To which issue would you like to add this comment: ');
 
             # ToDo: decide whether we let them choose an arbitrary issue, for
@@ -123,8 +127,12 @@ 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.");
-        my $ans = CIL::Utils::ans('Would you like to add this message as an issue shown above (y/n): ');
-        return unless $ans eq 'y';
+        if ($noquestions) {
+            CIL::Utils->msg('Running in non interactive mode, so just adding it as a new one without asking"!');
+        } 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';
+        }
 
         CIL::Utils->add_issue_loop($cil, undef, $issue);
     }