CLI: completion with aliases and alphanet
This commit is contained in:
parent
466831c179
commit
2fa77489bc
@ -1,18 +1,56 @@
|
|||||||
_tezos-client_complete()
|
_tezos-client_complete()
|
||||||
{
|
{
|
||||||
local cur_word prev_word type_list
|
local cur_word prev_word type_list
|
||||||
|
|
||||||
cur_word="${COMP_WORDS[COMP_CWORD]}"
|
cur_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
|
prev_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
|
||||||
# Tezos script
|
# Tezos script
|
||||||
script=${COMP_WORDS[0]}
|
script=${COMP_WORDS[0]}
|
||||||
reply=$($script bash_autocomplete "$prev_word" "$cur_word" ${COMP_WORDS[@]})
|
if [ -z "$(type -P $script)" ]; then
|
||||||
|
local tmp="$(alias $script)"
|
||||||
COMPREPLY=($(compgen -W "$reply"))
|
tmp="${tmp#*=}"
|
||||||
|
tmp="${tmp%\'}"
|
||||||
|
script="${tmp#\'}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
reply=$($script bash_autocomplete "$prev_word" "$cur_word" ${COMP_WORDS[@]})
|
||||||
|
|
||||||
|
COMPREPLY=($(compgen -W "$reply" -- $cur_word))
|
||||||
|
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_tezos-alphanet_complete()
|
||||||
|
{
|
||||||
|
script="${COMP_WORDS[0]}"
|
||||||
|
second="${COMP_WORDS[1]}"
|
||||||
|
cur_word="${COMP_WORDS[COMP_CWORD]}"
|
||||||
|
case "$second" in
|
||||||
|
container)
|
||||||
|
COMPREPLY=($(compgen -W "start stop status" -- $cur_word));;
|
||||||
|
node)
|
||||||
|
COMPREPLY=($(compgen -W "start stop status log" -- $cur_word));;
|
||||||
|
baker)
|
||||||
|
COMPREPLY=($(compgen -W "start stop status log" -- $cur_word));;
|
||||||
|
endorser)
|
||||||
|
COMPREPLY=($(compgen -W "start stop status log" -- $cur_word));;
|
||||||
|
client)
|
||||||
|
;;
|
||||||
|
# prev_word="${COMP_WORDS[COMP_CWORD-1]}"
|
||||||
|
# unset COMP_WORDS[0]
|
||||||
|
# echo $script client bash_autocomplete "$prev_word" "$cur_word" ${COMP_WORDS[@]:1} > /tmp/completions
|
||||||
|
# reply=$($script client bash_autocomplete "$prev_word" "$cur_word" ${COMP_WORDS[@]:1})
|
||||||
|
# COMPREPLY=$($(compgen -W "$reply" -- $cur_word));;
|
||||||
|
*)
|
||||||
|
COMPREPLY=($(compgen -W "start restart \
|
||||||
|
clear status stop kill head \
|
||||||
|
go_alpha_go shell client check_script update_script \
|
||||||
|
container node baker endorser" -- $cur_word));;
|
||||||
|
esac
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Register _pss_complete to provide completion for the following commands
|
# Register _pss_complete to provide completion for the following commands
|
||||||
complete -F _tezos-client_complete tezos-client
|
complete -F _tezos-client_complete tezos-client
|
||||||
|
complete -F _tezos-alphanet_complete alphanet.sh
|
||||||
|
@ -29,6 +29,7 @@ if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ;
|
|||||||
alias tezos-client="$client" ;
|
alias tezos-client="$client" ;
|
||||||
alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and key dictator" ;
|
alias tezos-activate-alpha="$client -block genesis activate protocol ProtoALphaALphaALphaALphaALphaALphaALphaALphaDdp3zK with fitness 1 and key dictator" ;
|
||||||
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-client tezos-activate-alpha tezos-client-reset" ;
|
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-client tezos-activate-alpha tezos-client-reset" ;
|
||||||
|
alias tezos-autocomplete="source \"$script_dir/bash-completion.sh\"" ;
|
||||||
trap tezos-client-reset EXIT ;
|
trap tezos-client-reset EXIT ;
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
@ -50,4 +51,8 @@ protocol than used by the alphanet by running:
|
|||||||
Warning: all the client data will be removed when you close this shell
|
Warning: all the client data will be removed when you close this shell
|
||||||
or if you run this command a second time.
|
or if you run this command a second time.
|
||||||
|
|
||||||
|
Activate tab completion by running:
|
||||||
|
|
||||||
|
tezos-autocomplete
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
Loading…
Reference in New Issue
Block a user