use strict;
use warnings;
-use Data::Dumper;
-
use Getopt::Mixed "nextOption";
use Digest::MD5 qw(md5_hex);
use File::Touch;
'path>p', # for 'add'
'f=s', # f = filename
'filename>f', # for 'extract'
+ 's=s', # s = status
+ 'status>s', # for 'summary', 'list'
+ 'l=s', # l = label
+ 'label>l', # for 'summary, 'list'
'help',
'version',
}
sub cmd_list {
- my ($cil) = @_;
+ my ($cil, $args) = @_;
check_paths($cil);
# find all the issues
my $issues = $cil->get_issues();
+ $issues = filter_issues( $issues, $args );
if ( @$issues ) {
foreach my $issue ( sort { $a->Inserted cmp $b->Inserted } @$issues ) {
separator();
}
sub cmd_summary {
- my ($cil) = @_;
+ my ($cil, $args) = @_;
check_paths($cil);
# find all the issues
my $issues = $cil->get_issues();
+ $issues = filter_issues( $issues, $args );
if ( @$issues ) {
separator();
foreach my $issue ( @$issues ) {
}
}
+sub filter_issues {
+ my ($issues, $args) = @_;
+
+ return unless %$args;
+
+ # take a copy of the whole lot first (so we don't destroy the input list)
+ my @new_issues = @$issues;
+
+ # firstly, get out the Statuses we want
+ if ( defined $args->{s} ) {
+ @new_issues = grep { $_->Status eq $args->{s} } @new_issues;
+ }
+
+ # then see if we want a particular label (could be a bit nicer)
+ if ( defined $args->{l} ) {
+ my @tmp;
+ foreach my $issue ( @new_issues ) {
+ push @tmp, $issue
+ if grep { $_ eq $args->{l} } @{$issue->Labels};
+ }
+ @new_issues = @tmp;
+ }
+
+ return \@new_issues;
+}
+
## ----------------------------------------------------------------------------
# input/output
Commands:
init [--path=PATH]
add
- summary
- list
+ summary [--status=STATUS] [--label=LABEL]
+ list [--status=STATUS] [--label=LABEL]
show ISSUE
status ISSUE NEW_STATUS
edit ISSUE
$ cil init
$ cil summary
$ cil list
+ $ cil list --status=New
+ $ cil list --label=Release-v0.1
$ cil add
... added issue 'cafebabe' ...
Creates a local '.cil' file and an 'issues' directory. If PATH is specified,
the config file and directory will be created in the destination directory.
-=item summary
+=item summary [--status=STATUS] [--label=LABEL]
-Displays a one line summary for each issue.
+Displays a one line summary for each issue. You may filter on both the Status
+and Label fields.
-=item list
+=item list [--status=STATUS] [--label=LABEL]
-Shows each issue with more information.
+Shows each issue with more information. You may filter on both the Status and
+Label fields.
=item add
--- /dev/null
+Issue: 85eceee9
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2008-06-23T12:07:44
+Updated: 2008-06-23T12:07:44
+
+Added both --status and --label.
+
+In the case of Status, it tests for equality.
+
+In the case of Label, it tests that the issue has at least one label of the one
+specified.
Summary: Ability to filter the issues lists (summary and list)
-Status: New
+Status: InProgress
CreatedBy: Andrew Chilton <andychilton@gmail.com>
AssignedTo: Andrew Chilton <andychilton@gmail.com>
Label: Milestone-v0.3
Label: Release-v0.2
Label: Type-Enhancement
+Comment: 7eb313cd
Inserted: 2008-06-23T12:05:33
-Updated: 2008-06-23T12:05:33
+Updated: 2008-06-23T12:08:05
The ability to filter on various things would be nice. For example using these
list commands, though summary should work the same way: