From 2fca0c68322dfd84005801ce944acd143aeed389 Mon Sep 17 00:00:00 2001 From: Andrew Chilton Date: Sat, 28 Jun 2008 00:35:45 +1200 Subject: [PATCH] Added --is-open and --is-closed. --- README | 14 ++++- bin/cil | 104 +++++++++++++++++++++++++++++++++----- etc/bash_completion.d/cil | 2 +- lib/CIL/Issue.pm | 16 ++++++ 4 files changed, 122 insertions(+), 14 deletions(-) diff --git a/README b/README index 607b470..ce882d6 100644 --- 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 eb06385..53d7bf2 100755 --- 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 diff --git a/etc/bash_completion.d/cil b/etc/bash_completion.d/cil index 921f8f0..3ead8a6 100644 --- a/etc/bash_completion.d/cil +++ b/etc/bash_completion.d/cil @@ -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=() diff --git a/lib/CIL/Issue.pm b/lib/CIL/Issue.pm index 6683860..6b0bc0e 100644 --- a/lib/CIL/Issue.pm +++ b/lib/CIL/Issue.pm @@ -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; ## ---------------------------------------------------------------------------- -- 2.39.5