-
-
Notifications
You must be signed in to change notification settings - Fork 624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: CLI_ARGS completion for fish and zsh (#1843) #1844
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,13 @@ function __task_list() { | |
taskfile=${(Qv)opt_args[(i)-t|--taskfile]} | ||
taskfile=${taskfile//\~/$HOME} | ||
|
||
for arg in "${words[@]:0:$CURRENT}"; do | ||
if [[ "$arg" = "--" ]]; then | ||
# Use default completion for words after `--` as they are CLI_ARGS. | ||
_default | ||
return 0 | ||
fi | ||
done | ||
|
||
if [[ -n "$taskfile" && -f "$taskfile" ]]; then | ||
enabled=1 | ||
|
@@ -40,6 +47,7 @@ function __task_list() { | |
|
||
_task() { | ||
_arguments \ | ||
-S \ | ||
'(-C --concurrency)'{-C,--concurrency}'[limit number of concurrent tasks]: ' \ | ||
'(-p --parallel)'{-p,--parallel}'[run command-line tasks in parallel]' \ | ||
'(-f --force)'{-f,--force}'[run even if task is up-to-date]' \ | ||
|
@@ -55,13 +63,13 @@ _task() { | |
'(-t --taskfile)'{-t,--taskfile}'[specify a different taskfile]:taskfile:_files' \ | ||
'(-v --verbose)'{-v,--verbose}'[verbose mode]' \ | ||
'(-w --watch)'{-w,--watch}'[watch-mode for given tasks, re-run when inputs change]' \ | ||
'(operation)*: :__task_list' \ | ||
+ '(operation)' \ | ||
{-l,--list}'[list describable tasks]' \ | ||
{-a,--list-all}'[list all tasks]' \ | ||
{-i,--init}'[create new Taskfile.yml]' \ | ||
'(-*)'{-h,--help}'[show help]' \ | ||
'(-*)--version[show version and exit]' \ | ||
'*: :__task_list' | ||
'(*)'{-l,--list}'[list describable tasks]' \ | ||
'(*)'{-a,--list-all}'[list all tasks]' \ | ||
'(*)'{-i,--init}'[create new Taskfile.yml]' \ | ||
'(- *)'{-h,--help}'[show help]' \ | ||
'(- *)--version[show version and exit]' \ | ||
Comment on lines
-62
to
+72
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. - (-*)--version
+ (- *)--version I suppose (The parentheses specify groups of arguments to prevent suggestions. |
||
} | ||
|
||
# don't run the completion function when being source-ed or eval-ed | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Task-name completions didn't work except for the first positional argument in zsh, but this has been fixed as well.
(Argument specifications after
+ '(operation)'
become mutually exclusive options. In the previous code,*: :__task_list
also prevented other task names from being suggested when one task name is specified in a command line.)