'add', # for 'add', 'comment'
'commit', # for 'add', 'comment'
'batch', # for 'am'
+ 'remove', # for 'label'
'help',
'version',
);
'add' => 1,
'commit' => 1,
'batch' => 1,
+ 'remove' => 1,
);
## ----------------------------------------------------------------------------
--- /dev/null
+Issue: 5ec585b1
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2010-01-23T06:37:08
+Updated: 2010-01-23T06:37:20
+
+Now done. Should remove the correct label specified.
Summary: Add a cil label --remove command
-Status: New
+Status: Finished
CreatedBy: Andrew Chilton <andychilton@gmail.com>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
Label: Milestone-v0.06
+Comment: 043f8971
Inserted: 2010-01-22T01:41:59
-Updated: 2010-01-22T01:43:31
+Updated: 2010-01-23T06:37:44
Currently you can 'cil label MyLabel cafebabe' but you can't remove it. Add the
following option:
- $ cil label --remote MyLabel cafebabe
+ $ cil label --remove MyLabel cafebabe
CIL::Utils->fatal("provide a valid label to add to this issue");
}
- # for every issue, read it it and add the label
+ # for every issue
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 );
+ # decide whether we are adding or removing this label
+ if ( $args->{remove} ) {
+ $issue->remove_label( $label );
+ }
+ else {
+ $issue->add_label( $label );
+ }
+
+ # save
$issue->save($cil);
# if we want to add or commit this issue
$self->flag_as_updated();
}
+sub remove_label {
+ my ($self, $label) = @_;
+
+ croak 'provide a label when removing one'
+ unless defined $label;
+
+ # remove this label
+ @{$self->{data}{Label}} = grep { $_ ne $label } @{$self->{data}{Label}};
+ $self->flag_as_updated();
+}
+
sub add_comment {
my ($self, $comment) = @_;