]> git.mjollnir.org Git - cil.git/commitdiff
Added --is-open and --is-closed.
authorAndrew Chilton <andychilton@gmail.com>
Fri, 27 Jun 2008 12:35:45 +0000 (00:35 +1200)
committerAndrew Chilton <andychilton@gmail.com>
Fri, 27 Jun 2008 12:35:45 +0000 (00:35 +1200)
README
bin/cil
etc/bash_completion.d/cil
lib/CIL/Issue.pm

diff --git a/README b/README
index 607b47082caaafb570bdb830d0223b0b4eb16d8d..ce882d60664d104ffafcb058cc72a2c467aff679 100644 (file)
--- a/README
+++ b/README
@@ -32,15 +32,27 @@ list all the issues by using the 'list' command:
 
  $ cil list
 
+When listing the issues, they can also be filtered:
+
+ $ cil list --status=New
+ $ cil list --label=Type-Enhancement
+ $ cil list --is-open
+ $ cil list --label=Milestone-v0.3 --is-open
+
 You can see what the issue name is by looking at the 'Issue' title. Imagine it
 is 'cafebabe' (which by default is the time from epoch). To see your issue
 again, use the 'show' command:
 
  $ cil show cafebabe
 
-Another reporting command is 'summary':
+Another reporting command is 'summary' for which all the filter options also
+apply:
 
  $ cil summary
+ $ cil summary --status=New
+ $ cil summary --label=Type-Enhancement
+ $ cil summary --is-open
+ $ cil summary --label=Milestone-v0.3 --is-open
 
 The columns show 'Name', 'Status', 'CreatedBy' and 'Summary'.
 
diff --git a/bin/cil b/bin/cil
index eb063856ddf8f789e7559ba5abee67f14481f1ac..53d7bf2a31168302c873018f7790e291fb8446f0 100755 (executable)
--- a/bin/cil
+++ b/bin/cil
@@ -39,6 +39,7 @@ my $y = 'y';
 use constant VERSION => '0.2.1';
 
 my @IN_OPTS = (
+    # strings
     'p=s',          # p = path
     'path>p',       # for 'add'
     'f=s',          # f = filename
@@ -48,13 +49,18 @@ my @IN_OPTS = (
     'l=s',          # l = label
     'label>l',      # for 'summary, 'list'
 
+    # booleans
+    'is-open',
+    'is-closed',
     'help',
     'version',
 );
 
 my %BOOLEAN_ARGS = (
-    help    => 1,
-    version => 1,
+    'help'      => 1,
+    'version'   => 1,
+    'is-open'   => 1,
+    'is-closed' => 1,
 );
 
 my $gan = $ENV{GIT_AUTHOR_NAME} || 'Your Name';
@@ -149,7 +155,7 @@ sub cmd_list {
 
     # find all the issues
     my $issues = $cil->get_issues();
-    $issues = filter_issues( $issues, $args );
+    $issues = filter_issues( $cil, $issues, $args );
     if ( @$issues ) {
         foreach my $issue ( sort { $a->Inserted cmp $b->Inserted } @$issues ) {
             separator();
@@ -169,7 +175,7 @@ sub cmd_summary {
 
     # find all the issues
     my $issues = $cil->get_issues();
-    $issues = filter_issues( $issues, $args );
+    $issues = filter_issues( $cil, $issues, $args );
     if ( @$issues ) {
         separator();
         foreach my $issue ( @$issues ) {
@@ -424,7 +430,7 @@ sub check_paths {
 }
 
 sub filter_issues {
-    my ($issues, $args) = @_;
+    my ($cil, $issues, $args) = @_;
 
     # don't filter if we haven't been given anything
     return $issues unless %$args;
@@ -447,6 +453,16 @@ sub filter_issues {
         @new_issues = @tmp;
     }
 
+    # filter out dependent on open/closed
+    if ( defined $args->{'is-open'} ) {
+        # just get the open issues
+        @new_issues = grep { $_->is_open($cil) } @new_issues;
+    }
+    if ( defined $args->{'is-closed'} ) {
+        # just get the closed issues
+        @new_issues = grep { $_->is_closed($cil) } @new_issues;
+    }
+
     return \@new_issues;
 }
 
@@ -671,12 +687,12 @@ and attachments as local files which you can check in to your repository.
 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 [--status=STATUS] [--label=LABEL]
+=item summary [--status=STATUS] [--label=LABEL] [--is-open] [--is-closed]
 
 Displays a one line summary for each issue. You may filter on both the Status
 and Label fields.
 
-=item list [--status=STATUS] [--label=LABEL]
+=item list [--status=STATUS] [--label=LABEL] [--is-open] [--is-closed]
 
 Shows each issue with more information. You may filter on both the Status and
 Label fields.
@@ -713,19 +729,83 @@ otherwise it will use the original one saved along with the attachment.
 
 =back
 
+=head1 .cil
+
+The C<.cil> file is used to configure bits and pieces within cil for this
+particular issue list. The following options are available and where stated,
+may be declared multiple times:
+
+The C<.cil> file is fairly simple and an example can be seen here:
+
+    StatusStrict: 1
+    StatusAllowedList: New
+    StatusAllowedList: InProgress
+    StatusAllowedList: Finished
+    StatusOpenList: New
+    StatusOpenList: InProgress
+    StatusClosedList: Finished
+    LabelStrict: 1
+    LabelAllowedList: Type-Enhancement
+    LabelAllowedList: Type-Defect
+    LabelAllowedList: Priority-High
+    LabelAllowedList: Priority-Medium
+    LabelAllowedList: Priority-Low
+
+=over
+
+=item StatusStrict
+
+Default: 0, Type: Boolean (0/1)
+
+If this is set to a true value then cil checks that the status you enter into
+an issue (after adding or editing) is also in the allowed list (see
+StatusAllowedList).
+
+=item StatusAllowedList
+
+Default: empty, Type: List
+
+This list is checked against when adding or editing issues but only if you have
+StatusStrict on.
+
+=item StatusOpenList
+
+Default: empty, Type: List
+
+This list is checked against when filtering with --is-open.
+
+=item StatusClosedList
+
+Default: empty, Type: List
+
+This list is checked against when filtering with --is-closed.
+
+=item LabelStrict
+
+Default: 0, Type: Boolean (0/1)
+
+This determines that labels you enter are checked against LabelAllowedList. Set
+to 1 if you require this feature.
+
+=item LabelAllowedList
+
+Default: empty, Type: List
+
+This determines which labels are allowed if you have turned on LabelStrict.
+
+=back
+
 =head1 BUGS
 
 Probably. Let me know :-)
 
 =head1 TODO
 
-There is a number of things to do. High on the list are:
-
-* the ability to set Statuses from the command line
+To get a ToDo list for cil, clone the repo, find the issues/ dir and type:
 
-* set where you want your issues (from a .cil file)
+    $ cil --is-open
 
-* simple search first, proper search and indexing second
+This gives the current outstanding issues in cil.
 
 =head1 AUTHOR
 
index 921f8f01382479864366e1c698e39fe00ac3014f..3ead8a600dadf692c693cb7dc2b803d7412f2a8b 100644 (file)
@@ -37,7 +37,7 @@ _cil()
     local cur prev opts
 
     # constants
-    opts="--help --version --path --status --label --filename"
+    opts="--help --version --path --status --label --filename --is-open --is-closed"
     commands="init add summary list show status edit comment attach extract"
 
        COMPREPLY=()
index 6683860fbf628ac769c053b9ca86413b91b9762c..6b0bc0e0c80b7324f65ade7f6416af1bb08f3c78 100644 (file)
@@ -170,6 +170,22 @@ sub Attachments {
     return $self->{data}{Attachment};
 }
 
+sub is_open {
+    my ($self, $cil) = @_;
+
+    # check against the list of Open Statuses
+    my $open = $cil->StatusOpen();
+    return exists $open->{$self->Status};
+}
+
+sub is_closed {
+    my ($self, $cil) = @_;
+
+    # check against the list of Closed Statuses
+    my $closed = $cil->StatusClosed();
+    return exists $closed->{$self->Status};
+}
+
 ## ----------------------------------------------------------------------------
 1;
 ## ----------------------------------------------------------------------------