Add the --created-by and --assigned-to filters.
authorAndrew Chilton <andychilton@gmail.com>
Fri, 27 Jun 2008 13:24:03 +0000 (01:24 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Fri, 27 Jun 2008 13:24:03 +0000 (01:24 +1200)
bin/cil
debian-etch/control
debian-lenny/control
etc/bash_completion.d/cil
issues/c_02a9bb68.cil [new file with mode: 0644]
issues/i_85eceee9.cil
lib/CIL/Issue.pm
lib/CIL/Utils.pm

diff --git a/bin/cil b/bin/cil
index 53d7bf2a31168302c873018f7790e291fb8446f0..4bc39fede69ffbebce84b4403f709d8b7b56d96d 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -48,10 +48,14 @@ my @IN_OPTS = (
     'status>s',     # for 'summary', 'list'
     'l=s',          # l = label
     'label>l',      # for 'summary, 'list'
+    'c=s',          # c = created-by
+    'created-by>c', # for 'summary', 'list'
+    'a=s',          # a = assigned_to
+    'assigned-to>a',# for 'summary', 'list'
 
     # booleans
-    'is-open',
-    'is-closed',
+    'is-open',      # for 'summary', 'list'
+    'is-closed',    # for 'summary', 'list'
     'help',
     'version',
 );
@@ -463,6 +467,16 @@ sub filter_issues {
         @new_issues = grep { $_->is_closed($cil) } @new_issues;
     }
 
+    # filter out 'created by'
+    if ( defined $args->{c} ) {
+        @new_issues = grep { $args->{c} eq $_->created_by_email } @new_issues;
+    }
+
+    # filter out 'assigned to'
+    if ( defined $args->{a} ) {
+        @new_issues = grep { $args->{a} eq $_->assigned_to_email } @new_issues;
+    }
+
     return \@new_issues;
 }
 
index ebac13441701faf869d643fda68b8f1405c1f282..ded0c34771fa771f0bdd58cb639f74df347b7c1c 100644 (file)
@@ -11,7 +11,7 @@ Package: cil
 Section: perl
 Priority: optional
 Architecture: all
-Depends: ${perl:Depends}, libgetopt-mixed-perl, libfile-touch-perl, libfile-slurp-perl, libclass-accessor-perl, libdatetime-perl
+Depends: ${perl:Depends}, libgetopt-mixed-perl, libfile-touch-perl, libfile-slurp-perl, libclass-accessor-perl, libdatetime-perl, libemail-find-perl
 Description: command line issue tracker
  'cil' allows easy command-line creation of an issue tracker. It saves each
  issue locally and in plain text. Commands are given such that these issues can
index ebac13441701faf869d643fda68b8f1405c1f282..ded0c34771fa771f0bdd58cb639f74df347b7c1c 100644 (file)
@@ -11,7 +11,7 @@ Package: cil
 Section: perl
 Priority: optional
 Architecture: all
-Depends: ${perl:Depends}, libgetopt-mixed-perl, libfile-touch-perl, libfile-slurp-perl, libclass-accessor-perl, libdatetime-perl
+Depends: ${perl:Depends}, libgetopt-mixed-perl, libfile-touch-perl, libfile-slurp-perl, libclass-accessor-perl, libdatetime-perl, libemail-find-perl
 Description: command line issue tracker
  'cil' allows easy command-line creation of an issue tracker. It saves each
  issue locally and in plain text. Commands are given such that these issues can
index 3ead8a600dadf692c693cb7dc2b803d7412f2a8b..3a570876e9e82527ec39701bb4e56c17670f5399 100644 (file)
@@ -37,7 +37,7 @@ _cil()
     local cur prev opts
 
     # constants
-    opts="--help --version --path --status --label --filename --is-open --is-closed"
+    opts="--help --version --path --status --label --filename --is-open --is-closed --assigned-to --created-by"
     commands="init add summary list show status edit comment attach extract"
 
        COMPREPLY=()
diff --git a/issues/c_02a9bb68.cil b/issues/c_02a9bb68.cil
new file mode 100644 (file)
index 0000000..554d4a3
--- /dev/null
@@ -0,0 +1,13 @@
+Issue: 85eceee9
+CreatedBy: Andrew Chilton <andychilton@gmail.com>
+Inserted: 2008-06-27T13:18:47
+Updated: 2008-06-27T13:20:01
+
+Added the --created-by and --assigned-to filters.
+
+These work just on the email address and not the whole field. E.g.
+
+ $ cil list --created-by=andy@example.com
+ $ cil list --assigned-to=andy@example.org
+
+The short options for these are -c and -a.
index 8f82740ed37d7cfad865543da1e0d7a41261a7f6..1ea9c2ae8871d437b0d4be596ddd5776c38bdf13 100644 (file)
@@ -5,10 +5,11 @@ AssignedTo: Andrew Chilton <andychilton@gmail.com>
 Label: Milestone-v0.3
 Label: Release-v0.2.0
 Label: Type-Enhancement
+Comment: 02a9bb68
 Comment: 4b71d0c3
 Comment: 7eb313cd
 Inserted: 2008-06-23T12:05:33
-Updated: 2008-06-27T12:40:51
+Updated: 2008-06-27T13:20:01
 
 The ability to filter on various things would be nice. For example using these
 list commands, though summary should work the same way:
index 6b0bc0e0c80b7324f65ade7f6416af1bb08f3c78..904a93b10aa98889114ad316f988a799bb076aa5 100644 (file)
@@ -186,6 +186,18 @@ sub is_closed {
     return exists $closed->{$self->Status};
 }
 
+sub assigned_to_email {
+    my ($self) = @_;
+
+    return CIL::Utils->extract_email_address( $self->AssignedTo );
+}
+
+sub created_by_email {
+    my ($self) = @_;
+
+    return CIL::Utils->extract_email_address( $self->CreatedBy );
+}
+
 ## ----------------------------------------------------------------------------
 1;
 ## ----------------------------------------------------------------------------
index fa43d2e8c14e8cb03acc298457cbbcc6cc25a025..e9611cf648a375c5a3b5f517ef839bd522510d97 100644 (file)
@@ -26,6 +26,7 @@ use warnings;
 use Carp;
 use File::Slurp;
 use File::Temp qw(tempfile);
+use Email::Find;
 use POSIX qw(getpgrp tcgetpgrp);
 use Fcntl qw(:DEFAULT :flock);
 
@@ -182,6 +183,21 @@ sub ensure_interactive {
     return;
 }
 
+sub extract_email_address {
+    my ($class, $text) = @_;
+
+    my $email_address;
+    my $num_found = find_emails(
+        $text,
+        sub {
+            my ($mail_address, $text_email) = @_;
+            $email_address = $text_email;
+        }
+    );
+
+    return $email_address;
+}
+
 ## ----------------------------------------------------------------------------
 1;
 ## ----------------------------------------------------------------------------