Skip to content

Commit 7416b7d

Browse files
authored
feat(completion): let fish complete global tasks if --global (-g) is passed (#2134)
1 parent c1ab661 commit 7416b7d

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

completion/fish/task.fish

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
1-
set GO_TASK_PROGNAME task
1+
set -l GO_TASK_PROGNAME task
22

33
function __task_get_tasks --description "Prints all available tasks with their description" --inherit-variable GO_TASK_PROGNAME
4+
# Check if the global task is requested
5+
set -l global_task false
6+
commandline --current-process | read --tokenize --list --local cmd_args
7+
for arg in $cmd_args
8+
if test "_$arg" = "_--"
9+
break # ignore arguments to be passed to the task
10+
end
11+
if test "_$arg" = "_--global" -o "_$arg" = "_-g"
12+
set global_task true
13+
break
14+
end
15+
end
16+
417
# Read the list of tasks (and potential errors)
5-
$GO_TASK_PROGNAME --list-all 2>&1 | read -lz rawOutput
18+
if $global_task
19+
$GO_TASK_PROGNAME --global --list-all
20+
else
21+
$GO_TASK_PROGNAME --list-all
22+
end 2>&1 | read -lz rawOutput
623

724
# Return on non-zero exit code (for cases when there is no Taskfile found or etc.)
825
if test $status -ne 0

0 commit comments

Comments
 (0)