This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 228
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR enables shell completion via urfav In order to use it, you must source the correct shell completion script in cli/autocomplete/ with the env variable PROG=rio. For example, PROG=rio source $RIO_REPO_ROOT/cli/autocomplete/bash_autocomplete There is still more to be done in order to make this consumable by end users.
- Loading branch information
Showing
3 changed files
with
35 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#! /bin/bash | ||
|
||
: ${PROG:=$(basename ${BASH_SOURCE})} | ||
|
||
_cli_bash_autocomplete() { | ||
if [[ "${COMP_WORDS[0]}" != "source" ]]; then | ||
local cur opts base | ||
COMPREPLY=() | ||
cur="${COMP_WORDS[COMP_CWORD]}" | ||
if [[ "$cur" == "-"* ]]; then | ||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion ) | ||
else | ||
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion ) | ||
fi | ||
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) | ||
return 0 | ||
fi | ||
} | ||
|
||
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete $PROG | ||
unset PROG |
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,13 @@ | ||
#compdef $PROG | ||
|
||
_cli_zsh_autocomplete() { | ||
|
||
local -a opts | ||
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}") | ||
|
||
_describe 'values' opts | ||
|
||
return | ||
} | ||
|
||
compdef _cli_zsh_autocomplete $PROG |
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