-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Breeze2 autocomplete did not work because we were using some old way of adding it (via click-complete). Since then click has native (and very well working) autocomplete support without any external dependencies needed. It cannnot automatically generate the completions but it is not needed either, because we can store generated completion scripts in our repo. We also move some imports to local and catch rich_click import error to minimize dependencies needed to get autocomplete working. Setup-autocomplete install (and upgrade if needed click in case it needs to be used by autocomplete script. Fixes: #21164 GitOrigin-RevId: 4fb929a60966e9cecbbb435efd375adcc4fff9d7
- Loading branch information
Showing
8 changed files
with
202 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
_Breeze2_completion() { | ||
local IFS=$'\n' | ||
local response | ||
|
||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _BREEZE2_COMPLETE=bash_complete $1) | ||
|
||
for completion in $response; do | ||
IFS=',' read type value <<< "$completion" | ||
|
||
if [[ $type == 'dir' ]]; then | ||
COMPREPLY=() | ||
compopt -o dirnames | ||
elif [[ $type == 'file' ]]; then | ||
COMPREPLY=() | ||
compopt -o default | ||
elif [[ $type == 'plain' ]]; then | ||
COMPREPLY+=($value) | ||
fi | ||
done | ||
|
||
return 0 | ||
} | ||
|
||
_Breeze2_completion_setup() { | ||
complete -o nosort -F _Breeze2_completion Breeze2 | ||
} | ||
|
||
_Breeze2_completion_setup; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function _Breeze2_completion; | ||
set -l response; | ||
|
||
for value in (env _BREEZE2_COMPLETE=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) Breeze2); | ||
set response $response $value; | ||
end; | ||
|
||
for completion in $response; | ||
set -l metadata (string split "," $completion); | ||
|
||
if test $metadata[1] = "dir"; | ||
__fish_complete_directories $metadata[2]; | ||
else if test $metadata[1] = "file"; | ||
__fish_complete_path $metadata[2]; | ||
else if test $metadata[1] = "plain"; | ||
echo $metadata[2]; | ||
end; | ||
end; | ||
end; | ||
|
||
complete --no-files --command Breeze2 --arguments "(_Breeze2_completion)"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#compdef Breeze2 | ||
|
||
_Breeze2_completion() { | ||
local -a completions | ||
local -a completions_with_descriptions | ||
local -a response | ||
(( ! $+commands[Breeze2] )) && return 1 | ||
|
||
response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) _BREEZE2_COMPLETE=zsh_complete Breeze2)}") | ||
|
||
for type key descr in ${response}; do | ||
if [[ "$type" == "plain" ]]; then | ||
if [[ "$descr" == "_" ]]; then | ||
completions+=("$key") | ||
else | ||
completions_with_descriptions+=("$key":"$descr") | ||
fi | ||
elif [[ "$type" == "dir" ]]; then | ||
_path_files -/ | ||
elif [[ "$type" == "file" ]]; then | ||
_path_files -f | ||
fi | ||
done | ||
|
||
if [ -n "$completions_with_descriptions" ]; then | ||
_describe -V unsorted completions_with_descriptions -U | ||
fi | ||
|
||
if [ -n "$completions" ]; then | ||
compadd -U -V unsorted -a completions | ||
fi | ||
} | ||
|
||
compdef _Breeze2_completion Breeze2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,7 +59,6 @@ install_requires = | |
pytest-xdist | ||
rich | ||
rich_click | ||
click_completion | ||
requests | ||
psutil | ||
inputimeout | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters