From 25b5081699292b45b3a54ff4fb3318f3c26814d8 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Mon, 9 Nov 2009 17:19:38 +1300 Subject: [PATCH] Make 'cil am' use a --batch option rather than an additional arg (which looks like a filename) --- bin/cil | 4 +++- lib/CIL/Command/Am.pm | 12 +++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/cil b/bin/cil index 12a4010..30f4e2b 100755 --- 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 diff --git a/lib/CIL/Command/Am.pm b/lib/CIL/Command/Am.pm index 4f6d2dd..5b763ea 100644 --- a/lib/CIL/Command/Am.pm +++ b/lib/CIL/Command/Am.pm @@ -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'; -- 2.39.5