mirror of
https://github.com/ACINQ/eclair.git
synced 2025-03-04 01:53:49 +01:00
bash completion script for eclair-cli (#443)
This commit is contained in:
parent
226aeb56d8
commit
69371f5f82
1 changed files with 39 additions and 0 deletions
39
contrib/eclair-cli.bash-completion
Normal file
39
contrib/eclair-cli.bash-completion
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# bash completion for eclair-cli
|
||||||
|
# copy to /etc/bash_completion.d/
|
||||||
|
# created by Stadicus
|
||||||
|
|
||||||
|
_eclair-cli()
|
||||||
|
{
|
||||||
|
local cur prev opts cmds
|
||||||
|
|
||||||
|
# eclair-cli might not be in $PATH
|
||||||
|
local eclaircli
|
||||||
|
ecli="$1"
|
||||||
|
|
||||||
|
COMPREPLY=()
|
||||||
|
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
|
case "$cur" in
|
||||||
|
-*=*)
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# works fine, but is too slow at the moment.
|
||||||
|
# allopts=$($eclaircli help 2>&1 | awk '$1 ~ /^"/ { sub(/,/, ""); print $1}' | sed 's/[":]//g')
|
||||||
|
allopts="connect open peers channels channel allnodes allchannels allupdates receive send close checkpayment getinfo help"
|
||||||
|
|
||||||
|
if ! [[ " $allopts " =~ " $prev " ]]; then # prevent double arguments
|
||||||
|
if [[ -z "$cur" || "$cur" =~ ^[a-z] ]]; then
|
||||||
|
opts=${allopts}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -z "$cur" || "$cur" =~ ^- ]]; then
|
||||||
|
cmds=$($ecli 2>&1 | awk '$1 ~ /^-/ { sub(/,/, ""); print $1}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
COMPREPLY=( $(compgen -W "${cmds} ${opts}" -- ${cur}) )
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
complete -F _eclair-cli eclair-cli
|
Loading…
Add table
Reference in a new issue