-
-
Notifications
You must be signed in to change notification settings - Fork 242
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix completions broken since click>=8
- Loading branch information
Showing
3 changed files
with
39 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,29 @@ | ||
_watson_completion() { | ||
local IFS=$' | ||
' | ||
COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \ | ||
COMP_CWORD=$COMP_CWORD \ | ||
_WATSON_COMPLETE=complete $1 ) ) | ||
local IFS=$'\n' | ||
local response | ||
|
||
response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD _WATSON_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 | ||
} | ||
|
||
_watson_completionetup() { | ||
local COMPLETION_OPTIONS="" | ||
local BASH_VERSION_ARR=(${BASH_VERSION//./ }) | ||
# Only BASH version 4.4 and later have the nosort option. | ||
if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then | ||
COMPLETION_OPTIONS="-o nosort" | ||
fi | ||
|
||
complete $COMPLETION_OPTIONS -F _watson_completion watson | ||
_watson_completion_setup() { | ||
complete -o nosort -F _watson_completion watson | ||
} | ||
|
||
_watson_completionetup; | ||
_watson_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