From 87dc0c170e979afba06ba1828f9713954549b8d4 Mon Sep 17 00:00:00 2001
From: Andrew Chilton <andychilton@gmail.com>
Date: Mon, 30 Nov 2009 22:33:37 +1300
Subject: [PATCH] Slight changes to a few commands

---
 bin/cil                   |  3 ++-
 lib/CIL/Command/Label.pm  | 19 ++++++++++---------
 lib/CIL/Command/Status.pm | 19 ++++++++++---------
 lib/CIL/Command/Work.pm   |  5 +++++
 4 files changed, 27 insertions(+), 19 deletions(-)

diff --git a/bin/cil b/bin/cil
index 6975256..0205e27 100755
--- a/bin/cil
+++ b/bin/cil
@@ -160,7 +160,8 @@ Commands:
    summary [FILTERS...]
    list    [FILTERS...]
    show    ISSUE
-   status  ISSUE NEW_STATUS
+   status  NEW_STATUS [ISSUES...]
+   label   NEW_LABEL [ISSUES...]
    steal   ISSUE
    edit    ISSUE
    comment ISSUE
diff --git a/lib/CIL/Command/Label.pm b/lib/CIL/Command/Label.pm
index e239491..8ddd330 100644
--- a/lib/CIL/Command/Label.pm
+++ b/lib/CIL/Command/Label.pm
@@ -31,20 +31,21 @@ use base qw(CIL::Command);
 sub name { 'label' }
 
 sub run {
-    my ($self, $cil, undef, $issue_name, $label) = @_;
+    my ($self, $cil, undef, $label, @issue_names) = @_;
 
     unless ( defined $label ) {
-        $cil->fatal("provide a label to add to this issue");
+        CIL::Utils->fatal("provide a valid label to add to this issue");
     }
 
-    # firstly, read the issue in
-    my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
+    # for every issue, read it it and add the label
+    foreach my $issue_name ( @issue_names ) {
+        # firstly, read the issue in
+        my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
 
-    # set the status for this issue
-    $issue->add_label( $label );
-    $issue->save($cil);
-
-    CIL::Utils->display_issue($cil, $issue);
+        # set the status for this issue
+        $issue->add_label( $label );
+        $issue->save($cil);
+    }
 }
 
 1;
diff --git a/lib/CIL/Command/Status.pm b/lib/CIL/Command/Status.pm
index 945c22a..529ca7b 100644
--- a/lib/CIL/Command/Status.pm
+++ b/lib/CIL/Command/Status.pm
@@ -31,20 +31,21 @@ use base qw(CIL::Command);
 sub name { 'status' }
 
 sub run {
-    my ($self, $cil, undef, $issue_name, $status) = @_;
+    my ($self, $cil, undef, $status, @issue_names) = @_;
 
     unless ( defined $status ) {
-        CIL::Utils->fatal("provide a status to set this issue to");
+        CIL::Utils->fatal("provide a valid status to set this issue to");
     }
 
-    # firstly, read the issue in
-    my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
+    # for every issue, read it it and set the Status
+    foreach my $issue_name ( @issue_names ) {
+        # firstly, read the issue in
+        my $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
 
-    # set the status for this issue
-    $issue->Status( $status );
-    $issue->save($cil);
-
-    CIL::Utils->display_issue($cil, $issue);
+        # set the label for this issue
+        $issue->Status( $status );
+        $issue->save($cil);
+    }
 }
 
 1;
diff --git a/lib/CIL/Command/Work.pm b/lib/CIL/Command/Work.pm
index 7ffc6dd..3a71c99 100644
--- a/lib/CIL/Command/Work.pm
+++ b/lib/CIL/Command/Work.pm
@@ -50,6 +50,11 @@ sub run {
     else {
         $cil->vcs->create_branch( $issue->name );
     }
+
+    # now that we've switched branches, load the issue in again (just in case)
+    $issue = CIL::Utils->load_issue_fuzzy( $cil, $issue_name );
+    $issue->Status( 'InProgress' );
+    $issue->save($cil);
 }
 
 1;
-- 
2.39.5