2022-05-22 16:15:15 +02:00
|
|
|
#!/bin/bash
|
2022-02-13 20:20:01 +01:00
|
|
|
|
2022-05-22 16:16:50 +02:00
|
|
|
GO_TASK_PROGNAME=task
|
|
|
|
|
|
|
|
_go_task_completion()
|
2019-08-30 09:59:03 +10:00
|
|
|
{
|
2022-02-13 20:20:01 +01:00
|
|
|
local cur
|
|
|
|
_get_comp_words_by_ref -n : cur
|
2019-08-30 09:59:03 +10:00
|
|
|
|
2022-02-13 20:20:01 +01:00
|
|
|
case "$cur" in
|
|
|
|
--*)
|
2022-05-22 16:15:15 +02:00
|
|
|
local options
|
|
|
|
options="$(_parse_help task)"
|
|
|
|
mapfile -t COMPREPLY < <(compgen -W "$options" -- "$cur")
|
2022-02-13 20:20:01 +01:00
|
|
|
;;
|
|
|
|
*)
|
2022-05-22 16:15:15 +02:00
|
|
|
local tasks
|
2022-05-22 16:16:50 +02:00
|
|
|
tasks="$($GO_TASK_PROGNAME --list-all 2> /dev/null | awk 'NR>1 { sub(/:$/,"",$2); print $2 }')"
|
2022-05-22 16:15:15 +02:00
|
|
|
mapfile -t COMPREPLY < <(compgen -W "$tasks" -- "$cur")
|
2022-02-13 20:20:01 +01:00
|
|
|
;;
|
|
|
|
esac
|
2019-08-30 09:59:03 +10:00
|
|
|
|
2022-02-13 20:20:01 +01:00
|
|
|
__ltrim_colon_completions "$cur"
|
2019-08-30 09:59:03 +10:00
|
|
|
}
|
|
|
|
|
2022-05-22 16:16:50 +02:00
|
|
|
complete -F _go_task_completion $GO_TASK_PROGNAME
|