Scripts: repair tezos-autocomplete, and make it work with emacs and zsh

This commit is contained in:
Benjamin Canou 2018-02-03 15:08:18 +01:00
parent 0352278621
commit 5ae24aa7a3
4 changed files with 20 additions and 17 deletions

View File

@ -387,7 +387,7 @@ Overrides `michelson-print-errors' and `michelson-highlight-errors'"
(lexical-let ((tmp-file (make-temp-file buffer-name)))
(write-region (point-min) (point-max) tmp-file nil 'no-message)
(let ((command
(append (split-string (expand-file-name michelson-client-command) " ")
(append (split-string michelson-client-command " ")
(list
"typecheck"
"program"

View File

@ -7,12 +7,6 @@ _tezos-client_complete()
# Tezos script
script=${COMP_WORDS[0]}
if [ -z "$(type -P $script)" ]; then
local tmp="$(alias $script)"
tmp="${tmp#*=}"
tmp="${tmp%\'}"
script="${tmp#\'}"
fi
reply=$($script bash_autocomplete "$prev_word" "$cur_word" ${COMP_WORDS[@]})
@ -53,4 +47,5 @@ _tezos-alphanet_complete()
# Register _pss_complete to provide completion for the following commands
complete -F _tezos-client_complete tezos-client
complete -F _tezos-client_complete tezos-admin-client
complete -F _tezos-alphanet_complete alphanet.sh

View File

@ -13,7 +13,7 @@ init_sandboxed_client() {
shift 1
rpc=$((18730 + id))
client_dir="$(mktemp -d -t tezos-client.XXXXXXXX)"
client_dir="$(mktemp -d -t tezos-tmp-client.XXXXXXXX)"
client_dirs+=("$client_dir")
client="$local_client -base-dir $client_dir -addr 127.0.0.1 -port $rpc"
@ -228,12 +228,20 @@ main () {
add_sandboxed_bootstrap_identities | sed -e 's/^/## /' 1>&2
mkdir -p $client_dir/bin
echo '#!/bin/sh' > $client_dir/bin/tezos-client
echo "exec $client \"\$@\"" >> $client_dir/bin/tezos-client
chmod +x $client_dir/bin/tezos-client
echo '#!/bin/sh' > $client_dir/bin/tezos-admin-client
echo "exec $client \"\$@\"" | sed s/tezos-client/tezos-adming-client/g >> $client_dir/bin/tezos-admin-client
chmod +x $client_dir/bin/tezos-admin-client
cat <<EOF
if type tezos-client-reset >/dev/null 2>&1 ; then tezos-client-reset; fi ;
alias tezos-client="$client" ;
PATH="$client_dir/bin:\$PATH" ; export PATH ;
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-autocomplete="source \"$bin_dir/bash-completion.sh\"" ;
alias tezos-client-reset="rm -rf \"$client_dir\"; unalias tezos-activate-alpha tezos-client-reset" ;
alias tezos-autocomplete="if [ \$ZSH_NAME ] ; then autoload bashcompinit ; bashcompinit ; fi ; source \"$bin_dir/bash-completion.sh\"" ;
trap tezos-client-reset EXIT ;
EOF

View File

@ -1197,11 +1197,11 @@ let handle_cli_errors ~stdout ~stderr ~global_options = function
Format.fprintf stdout "@." ;
return 0
| Autocomplete_command (completions) ->
Format.pp_print_list
Format.fprintf stdout "%a@."
(Format.pp_print_list
~pp_sep:Format.pp_print_newline
Format.pp_print_string
Format.std_formatter
completions;
Format.pp_print_string)
completions ;
return 0
| Help_flag commands ->
let format = if Unix.isatty Unix.stdout then `Ansi else `Plain in