Enhancement

- Improve bash completion for 'project:', 'depends:', and 'priority:'.
- 'projABC:' no longer expands (same for 'depends:' and 'priority:').
- 'proj:' only expands if abbreviation.minimum is less than 5
  (same for 'depends:' and 'priority:' and for other values of
  abbreviation.minimum).
- Unit tests for the above.
This commit is contained in:
Scott Kostyshak 2012-09-16 20:35:40 -04:00 committed by Paul Beckingham
parent ad3e249a64
commit d8a4aab85b
3 changed files with 75 additions and 16 deletions

View file

@ -14,6 +14,8 @@ Features
+ Virtual tags.
Bugs
+ No more bash completion of, for example, 'projABC:', or of 'proj:' if
abbreviation.minimum is greater than 4.
+ Fixed bug #1059, where CmdEdit was running garbage collection.
+ Fixed bug #1065, where CmdShow issued messages in incorrect situations.
+ Fixed bug #1060, where an error was not thrown correctly.

View file

@ -92,44 +92,57 @@ _task()
# echo "prev='$prev'"
# echo "prev2='$prev2'"
abbrev_min=$($taskcommand show | grep "abbreviation.minimum" | awk {'print $2'})
commands_aliases=$(echo $($taskcommand _commands; $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
opts="$commands_aliases $($taskcommand _ids) $($taskcommand _columns)"
case "${prev}" in
:)
case "${prev2}" in
dep*)
_task_offer_dependencies
dep|depe|depen|depend|depends)
if [ ${#prev2} -ge $abbrev_min ]; then
_task_offer_dependencies
fi
return 0
;;
pri*)
_task_offer_priorities
pri|prior|priori|priorit|priority)
if [ ${#prev2} -ge $abbrev_min ]; then
_task_offer_priorities
fi
return 0
;;
pro*)
_task_offer_projects
pro|proj|proje|projec|project)
if [ ${#prev2} -ge $abbrev_min ]; then
_task_offer_projects
fi
return 0
;;
esac
;;
*)
case "${cur}" in
pro*:*)
pro:*|proj:*|proje:*|projec:*|project:*)
_task_offer_projects
return 0
;;
:)
case "${prev}" in
dep*)
_task_offer_dependencies
dep|depe|depen|depend|depends)
if [ ${#prev} -ge $abbrev_min ]; then
_task_offer_dependencies
fi
return 0
;;
pri*)
_task_offer_priorities
pri|prior|priori|priorit|priority)
if [ ${#prev} -ge $abbrev_min ]; then
_task_offer_priorities
fi
return 0
;;
pro*)
_task_offer_projects
pro|proj|proje|projec|project)
if [ ${#prev} -ge $abbrev_min ]; then
_task_offer_projects
fi
return 0
;;
esac

View file

@ -28,13 +28,14 @@
use strict;
use warnings;
use Test::More tests => 7;
use Test::More tests => 25;
# Create the rc file.
if (open my $fh, '>', 'bug.rc')
{
print $fh "data.location=.\n";
print $fh "alias.samplealias=long\n";
print $fh "abbreviation.minimum=5\n";
close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
@ -76,14 +77,57 @@ if (open my $target, '>', 'task.sh')
}
# aliases should be expanded
my $output = qx{bash ./task.sh task sampleali};
my $output = qx{bash ./task.sh task sampleali 2>&1};
ok ($? == 0, 'Exit status check');
like ($output, qr/samplealias/, 'Aliases are expanded');
$output = qx{bash ./task.sh task m};
# commands should be expanded
$output = qx{bash ./task.sh task m 2>&1};
ok ($? == 0, 'Exit status check');
like ($output, qr/modify/, 'expansion of \'m\' includes \'modify\'');
# "project:" should be expanded correctly and dependent on abbreviation.minimum
qx{../src/task rc:bug.rc add testing project expansion project:todd 2>&1};
# note the spaces between "projABC", ":", and "to" for correct bash parsing
$output = qx{bash ./task.sh task projeABC : to 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/todd/, '\'projeABC:\' does not expand');
$output = qx{bash ./task.sh task proje : to 2>&1};
ok ($? == 0, 'Exit status check');
like ($output, qr/todd/, '\'proje:\' does expand');
$output = qx{bash ./task.sh task proj : to 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/todd/, '\'proj:\' does not expand if abbreviation.minimum is 5');
# "priority:" should be expanded correctly and dependent on abbreviation.minimum
$output = qx{bash ./task.sh task priorABC : 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/H/, '\'priorABC:\' does not expand');
$output = qx{bash ./task.sh task prior : 2>&1};
ok ($? == 0, 'Exit status check');
like ($output, qr/H/, '\'prior:\' does expand');
$output = qx{bash ./task.sh task prio : 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/H/, '\'prio:\' does not expand if abbreviation.minimum is 5');
# "depends:" should be expanded correctly and dependent on abbreviation.minimum
$output = qx{bash ./task.sh task depenABC : 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/1/, '\'depenABC:\' does not expand');
$output = qx{bash ./task.sh task depen : 2>&1};
ok ($? == 0, 'Exit status check');
like ($output, qr/1/, '\'depen:\' does expand');
$output = qx{bash ./task.sh task depe : 2>&1};
ok ($? == 0, 'Exit status check');
unlike ($output, qr/1/, '\'depe:\' does not expand if abbreviation.minimum is 5');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc task.sh);
ok (! -r 'pending.data' &&