mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
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:
parent
ad3e249a64
commit
d8a4aab85b
3 changed files with 75 additions and 16 deletions
|
@ -14,6 +14,8 @@ Features
|
||||||
+ Virtual tags.
|
+ Virtual tags.
|
||||||
|
|
||||||
Bugs
|
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 #1059, where CmdEdit was running garbage collection.
|
||||||
+ Fixed bug #1065, where CmdShow issued messages in incorrect situations.
|
+ Fixed bug #1065, where CmdShow issued messages in incorrect situations.
|
||||||
+ Fixed bug #1060, where an error was not thrown correctly.
|
+ Fixed bug #1060, where an error was not thrown correctly.
|
||||||
|
|
|
@ -92,44 +92,57 @@ _task()
|
||||||
# echo "prev='$prev'"
|
# echo "prev='$prev'"
|
||||||
# echo "prev2='$prev2'"
|
# 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" " ")
|
commands_aliases=$(echo $($taskcommand _commands; $taskcommand _aliases) | tr " " "\n"|sort|tr "\n" " ")
|
||||||
opts="$commands_aliases $($taskcommand _ids) $($taskcommand _columns)"
|
opts="$commands_aliases $($taskcommand _ids) $($taskcommand _columns)"
|
||||||
|
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
:)
|
:)
|
||||||
case "${prev2}" in
|
case "${prev2}" in
|
||||||
dep*)
|
dep|depe|depen|depend|depends)
|
||||||
_task_offer_dependencies
|
if [ ${#prev2} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_dependencies
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
pri*)
|
pri|prior|priori|priorit|priority)
|
||||||
_task_offer_priorities
|
if [ ${#prev2} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_priorities
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
pro*)
|
pro|proj|proje|projec|project)
|
||||||
_task_offer_projects
|
if [ ${#prev2} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_projects
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
case "${cur}" in
|
case "${cur}" in
|
||||||
pro*:*)
|
pro:*|proj:*|proje:*|projec:*|project:*)
|
||||||
_task_offer_projects
|
_task_offer_projects
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
:)
|
:)
|
||||||
case "${prev}" in
|
case "${prev}" in
|
||||||
dep*)
|
dep|depe|depen|depend|depends)
|
||||||
_task_offer_dependencies
|
if [ ${#prev} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_dependencies
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
pri*)
|
pri|prior|priori|priorit|priority)
|
||||||
_task_offer_priorities
|
if [ ${#prev} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_priorities
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
pro*)
|
pro|proj|proje|projec|project)
|
||||||
_task_offer_projects
|
if [ ${#prev} -ge $abbrev_min ]; then
|
||||||
|
_task_offer_projects
|
||||||
|
fi
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -28,13 +28,14 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 7;
|
use Test::More tests => 25;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'bug.rc')
|
if (open my $fh, '>', 'bug.rc')
|
||||||
{
|
{
|
||||||
print $fh "data.location=.\n";
|
print $fh "data.location=.\n";
|
||||||
print $fh "alias.samplealias=long\n";
|
print $fh "alias.samplealias=long\n";
|
||||||
|
print $fh "abbreviation.minimum=5\n";
|
||||||
|
|
||||||
close $fh;
|
close $fh;
|
||||||
ok (-r 'bug.rc', 'Created bug.rc');
|
ok (-r 'bug.rc', 'Created bug.rc');
|
||||||
|
@ -76,14 +77,57 @@ if (open my $target, '>', 'task.sh')
|
||||||
}
|
}
|
||||||
|
|
||||||
# aliases should be expanded
|
# 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');
|
ok ($? == 0, 'Exit status check');
|
||||||
like ($output, qr/samplealias/, 'Aliases are expanded');
|
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');
|
ok ($? == 0, 'Exit status check');
|
||||||
like ($output, qr/modify/, 'expansion of \'m\' includes \'modify\'');
|
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.
|
# Cleanup.
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc task.sh);
|
unlink qw(pending.data completed.data undo.data backlog.data synch.key bug.rc task.sh);
|
||||||
ok (! -r 'pending.data' &&
|
ok (! -r 'pending.data' &&
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue