Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
cli: Add completion stubs for bash/zsh/fish
Christopher Fredén committed 2 years ago
commit 29a69bad9e9c61b94d18cd8f1a6594edd818a967
parent 698652265a7a45959d8c2d3c7ddc1303361d3747
4 files changed +67 -0
added radicle-cli/completion/_rad.zsh
@@ -0,0 +1,23 @@
+
#compdef rad
+
# ZSH suggestion shim for Radicle CLI
+

+
# DEBUG:
+
# echo "\n\n\nstate:\t'$state'"
+
# echo "line:\t'$line'"
+
# echo "words:\t$words"
+

+
export _CLAP_COMPLETE_INDEX=$((${#words[@]} - 1))
+
# export _CLAP_COMPLETE_COMP_TYPE=9
+
# export _CLAP_COMPLETE_SPACE=false
+

+
local completions=($(rad complete --shell bash -- $words "" 2>/dev/null))
+

+
if [ -z "$completions" ]
+
then
+
  # If the completion list is empty, just continue with filename selection
+
  # _arguments '*::arguments: _normal'
+
  return
+
fi
+

+
# This is not a variable assignment, don't remove spaces!
+
_values = "${(ps:\v:)completions}"
added radicle-cli/completion/bash/_rad_bash_complete.sh
@@ -0,0 +1,19 @@
+

+
_clap_complete_rad() {
+
    export IFS=$'\013'
+
    export _CLAP_COMPLETE_INDEX=${COMP_CWORD}
+
    export _CLAP_COMPLETE_COMP_TYPE=${COMP_TYPE}
+
    if compopt +o nospace 2> /dev/null; then
+
        export _CLAP_COMPLETE_SPACE=false
+
    else
+
        export _CLAP_COMPLETE_SPACE=true
+
    fi
+
    COMPREPLY=( $("rad" complete --shell bash -- "${COMP_WORDS[@]}") )
+
    if [[ $? != 0 ]]; then
+
        unset COMPREPLY
+
    elif [[ $SUPPRESS_SPACE == 1 ]] && [[ "${COMPREPLY-}" =~ [=/:]$ ]]; then
+
        compopt -o nospace
+
    fi
+
}
+
complete -o nospace -o bashdefault -F _clap_complete_rad rad
+

added radicle-cli/completion/fish/_rad
@@ -0,0 +1 @@
+
complete -x -c rad -a "("'rad'" complete --shell fish -- (commandline --current-process --tokenize --cut-at-cursor) (commandline --current-token))"
added radicle-cli/completion/zsh/_rad
@@ -0,0 +1,24 @@
+
#compdef rad
+
# ZSH suggestion shim for Radicle CLI
+

+
# DEBUG:
+
# echo "\n\n\nstate:\t'$state'"
+
# echo "line:\t'$line'"
+
# echo "words:\t$words"
+

+
export IFS=$'\013'
+
export _CLAP_COMPLETE_INDEX=$((${#words[@]} - 1))
+
# export _CLAP_COMPLETE_COMP_TYPE=9
+
# export _CLAP_COMPLETE_SPACE=false
+

+
local completions=($(rad complete --shell bash -- $words "" 2>/dev/null))
+

+
if [ -z "$completions" ]
+
then
+
  # If the completion list is empty, just continue with filename selection
+
  # _arguments '*::arguments: _normal'
+
  return
+
fi
+

+
# This is not a variable assignment, don't remove spaces!
+
_values = "${(ps:\v:)completions}"