-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #319 from rhatdan/python
Fix handling of completions on MacOS
- Loading branch information
Showing
7 changed files
with
202 additions
and
20 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 |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#compdef ramalama | ||
# Run something, muting output or redirecting it to the debug stream | ||
# depending on the value of _ARC_DEBUG. | ||
# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC. | ||
__python_argcomplete_run() { | ||
if [[ -z "${ARGCOMPLETE_USE_TEMPFILES-}" ]]; then | ||
__python_argcomplete_run_inner "$@" | ||
return | ||
fi | ||
local tmpfile="$(mktemp)" | ||
_ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@" | ||
local code=$? | ||
cat "$tmpfile" | ||
rm "$tmpfile" | ||
return $code | ||
} | ||
|
||
__python_argcomplete_run_inner() { | ||
if [[ -z "${_ARC_DEBUG-}" ]]; then | ||
"$@" 8>&1 9>&2 1>/dev/null 2>&1 | ||
else | ||
"$@" 8>&1 9>&2 1>&9 2>&1 | ||
fi | ||
} | ||
|
||
_python_argcomplete() { | ||
local IFS=$'\013' | ||
local script="" | ||
if [[ -n "${ZSH_VERSION-}" ]]; then | ||
local completions | ||
completions=($(IFS="$IFS" \ | ||
COMP_LINE="$BUFFER" \ | ||
COMP_POINT="$CURSOR" \ | ||
_ARGCOMPLETE=1 \ | ||
_ARGCOMPLETE_SHELL="zsh" \ | ||
_ARGCOMPLETE_SUPPRESS_SPACE=1 \ | ||
__python_argcomplete_run ${script:-${words[1]}})) | ||
local nosort=() | ||
local nospace=() | ||
if is-at-least 5.8; then | ||
nosort=(-o nosort) | ||
fi | ||
if [[ "${completions-}" =~ ([^\\]): && "${match[1]}" =~ [=/:] ]]; then | ||
nospace=(-S '') | ||
fi | ||
_describe "${words[1]}" completions "${nosort[@]}" "${nospace[@]}" | ||
else | ||
local SUPPRESS_SPACE=0 | ||
if compopt +o nospace 2> /dev/null; then | ||
SUPPRESS_SPACE=1 | ||
fi | ||
COMPREPLY=($(IFS="$IFS" \ | ||
COMP_LINE="$COMP_LINE" \ | ||
COMP_POINT="$COMP_POINT" \ | ||
COMP_TYPE="$COMP_TYPE" \ | ||
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ | ||
_ARGCOMPLETE=1 \ | ||
_ARGCOMPLETE_SHELL="bash" \ | ||
_ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \ | ||
__python_argcomplete_run ${script:-$1})) | ||
if [[ $? != 0 ]]; then | ||
unset COMPREPLY | ||
elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then | ||
compopt -o nospace | ||
fi | ||
fi | ||
} | ||
if [[ -z "${ZSH_VERSION-}" ]]; then | ||
complete -o nospace -o default -o bashdefault -F _python_argcomplete ramalama | ||
else | ||
# When called by the Zsh completion system, this will end with | ||
# "loadautofunc" when initially autoloaded and "shfunc" later on, otherwise, | ||
# the script was "eval"-ed so use "compdef" to register it with the | ||
# completion system | ||
autoload is-at-least | ||
if [[ $zsh_eval_context == *func ]]; then | ||
_python_argcomplete "$@" | ||
else | ||
compdef _python_argcomplete ramalama | ||
fi | ||
fi |
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,17 @@ | ||
|
||
function __fish_ramalama_complete | ||
set -x _ARGCOMPLETE 1 | ||
set -x _ARGCOMPLETE_DFS \t | ||
set -x _ARGCOMPLETE_IFS \n | ||
set -x _ARGCOMPLETE_SUPPRESS_SPACE 1 | ||
set -x _ARGCOMPLETE_SHELL fish | ||
set -x COMP_LINE (commandline -p) | ||
set -x COMP_POINT (string length (commandline -cp)) | ||
set -x COMP_TYPE | ||
if set -q _ARC_DEBUG | ||
ramalama 8>&1 9>&2 1>&9 2>&1 | ||
else | ||
ramalama 8>&1 9>&2 1>/dev/null 2>&1 | ||
end | ||
end | ||
complete --command ramalama -f -a '(__fish_ramalama_complete)' |
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,81 @@ | ||
#compdef ramalama | ||
# Run something, muting output or redirecting it to the debug stream | ||
# depending on the value of _ARC_DEBUG. | ||
# If ARGCOMPLETE_USE_TEMPFILES is set, use tempfiles for IPC. | ||
__python_argcomplete_run() { | ||
if [[ -z "${ARGCOMPLETE_USE_TEMPFILES-}" ]]; then | ||
__python_argcomplete_run_inner "$@" | ||
return | ||
fi | ||
local tmpfile="$(mktemp)" | ||
_ARGCOMPLETE_STDOUT_FILENAME="$tmpfile" __python_argcomplete_run_inner "$@" | ||
local code=$? | ||
cat "$tmpfile" | ||
rm "$tmpfile" | ||
return $code | ||
} | ||
|
||
__python_argcomplete_run_inner() { | ||
if [[ -z "${_ARC_DEBUG-}" ]]; then | ||
"$@" 8>&1 9>&2 1>/dev/null 2>&1 | ||
else | ||
"$@" 8>&1 9>&2 1>&9 2>&1 | ||
fi | ||
} | ||
|
||
_python_argcomplete() { | ||
local IFS=$'\013' | ||
local script="" | ||
if [[ -n "${ZSH_VERSION-}" ]]; then | ||
local completions | ||
completions=($(IFS="$IFS" \ | ||
COMP_LINE="$BUFFER" \ | ||
COMP_POINT="$CURSOR" \ | ||
_ARGCOMPLETE=1 \ | ||
_ARGCOMPLETE_SHELL="zsh" \ | ||
_ARGCOMPLETE_SUPPRESS_SPACE=1 \ | ||
__python_argcomplete_run ${script:-${words[1]}})) | ||
local nosort=() | ||
local nospace=() | ||
if is-at-least 5.8; then | ||
nosort=(-o nosort) | ||
fi | ||
if [[ "${completions-}" =~ ([^\\]): && "${match[1]}" =~ [=/:] ]]; then | ||
nospace=(-S '') | ||
fi | ||
_describe "${words[1]}" completions "${nosort[@]}" "${nospace[@]}" | ||
else | ||
local SUPPRESS_SPACE=0 | ||
if compopt +o nospace 2> /dev/null; then | ||
SUPPRESS_SPACE=1 | ||
fi | ||
COMPREPLY=($(IFS="$IFS" \ | ||
COMP_LINE="$COMP_LINE" \ | ||
COMP_POINT="$COMP_POINT" \ | ||
COMP_TYPE="$COMP_TYPE" \ | ||
_ARGCOMPLETE_COMP_WORDBREAKS="$COMP_WORDBREAKS" \ | ||
_ARGCOMPLETE=1 \ | ||
_ARGCOMPLETE_SHELL="bash" \ | ||
_ARGCOMPLETE_SUPPRESS_SPACE=$SUPPRESS_SPACE \ | ||
__python_argcomplete_run ${script:-$1})) | ||
if [[ $? != 0 ]]; then | ||
unset COMPREPLY | ||
elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then | ||
compopt -o nospace | ||
fi | ||
fi | ||
} | ||
if [[ -z "${ZSH_VERSION-}" ]]; then | ||
complete -o nospace -o default -o bashdefault -F _python_argcomplete ramalama | ||
else | ||
# When called by the Zsh completion system, this will end with | ||
# "loadautofunc" when initially autoloaded and "shfunc" later on, otherwise, | ||
# the script was "eval"-ed so use "compdef" to register it with the | ||
# completion system | ||
autoload is-at-least | ||
if [[ $zsh_eval_context == *func ]]; then | ||
_python_argcomplete "$@" | ||
else | ||
compdef _python_argcomplete ramalama | ||
fi | ||
fi |
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,6 +1,6 @@ | ||
[project] | ||
name = "ramalama" | ||
version = "0.0.18" | ||
version = "0.0.19" | ||
dependencies = [ | ||
"argcomplete", | ||
"tqdm", | ||
|
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