Skip to content

Commit b201033

Browse files
committed
fix: autocomplete works with other binary than 'task'
1 parent 786813d commit b201033

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

completion/bash/task.bash

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# vim: set tabstop=2 shiftwidth=2 expandtab:
22

33
_GO_TASK_COMPLETION_LIST_OPTION='--list-all'
4+
TASK_CMD="${TASK_EXE:-task}"
45

56
function _task()
67
{
@@ -52,4 +53,4 @@ function _task()
5253
__ltrim_colon_completions "$cur"
5354
}
5455

55-
complete -F _task task
56+
complete -F _task "$TASK_CMD"

completion/fish/task.fish

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
set -l GO_TASK_PROGNAME task
1+
set -l GO_TASK_PROGNAME (if set -q GO_TASK_PROGNAME; echo $GO_TASK_PROGNAME; else if set -q TASK_EXE; echo $TASK_EXE; else; echo task; end)
22

33
function __task_get_tasks --description "Prints all available tasks with their description" --inherit-variable GO_TASK_PROGNAME
44
# Check if the global task is requested

completion/ps/task.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
using namespace System.Management.Automation
22

3-
Register-ArgumentCompleter -CommandName task -ScriptBlock {
3+
$TaskCmd = if ($env:TASK_EXE) { $env:TASK_EXE } else { "task" }
4+
5+
Register-ArgumentCompleter -CommandName $TaskCmd -ScriptBlock {
46
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
57

68
if ($commandName.StartsWith('-')) {
@@ -24,5 +26,5 @@ Register-ArgumentCompleter -CommandName task -ScriptBlock {
2426
return $completions.Where{ $_.CompletionText.StartsWith($commandName) }
2527
}
2628

27-
return $(task --list-all --silent) | Where-Object { $_.StartsWith($commandName) } | ForEach-Object { return $_ + " " }
29+
return $(& $commandName --list-all --silent) | Where-Object { $_.StartsWith($commandName) } | ForEach-Object { return $_ + " " }
2830
}

completion/zsh/_task

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#compdef task
2-
compdef _task task
32
typeset -A opt_args
3+
TASK_CMD="${TASK_EXE:-task}"
4+
compdef _task "$TASK_CMD"
45

56
_GO_TASK_COMPLETION_LIST_OPTION="${GO_TASK_COMPLETION_LIST_OPTION:---list-all}"
67

@@ -10,7 +11,7 @@ function __task_list() {
1011
local -i enabled=0
1112
local taskfile item task desc
1213

13-
cmd=(task)
14+
cmd=($TASK_CMD)
1415
taskfile=${(Qv)opt_args[(i)-t|--taskfile]}
1516
taskfile=${taskfile//\~/$HOME}
1617

0 commit comments

Comments
 (0)