mirror of https://github.com/hashicorp/consul
Consul can now set this up for you, see https://www.consul.io/docs/commands/index.html#autocompletion.pull/3833/head
parent
bfeb09983b
commit
5143b703e3
@ -1,264 +0,0 @@
|
||||
# This completion file has been inspired by the completion files of the Git and
|
||||
# the Docker projects.
|
||||
|
||||
__consulcomp() {
|
||||
local all c s=$'\n' IFS=' '$'\t'$'\n'
|
||||
local cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
|
||||
for c in $1; do
|
||||
case "$c$4" in
|
||||
--*=*) all="$all$c$4$s" ;;
|
||||
*) all="$all$c$4 $s" ;;
|
||||
esac
|
||||
done
|
||||
IFS=$s
|
||||
COMPREPLY=($(compgen -P "$2" -W "$all" -- "$cur"))
|
||||
return
|
||||
}
|
||||
|
||||
__consul_agent() {
|
||||
local subcommands="
|
||||
-advertise
|
||||
-advertise-wan
|
||||
-atlas
|
||||
-atlas-join
|
||||
-atlas-token
|
||||
-atlas-endpoint
|
||||
-bootstrap
|
||||
-bind
|
||||
-http-port
|
||||
-bootstrap-expect
|
||||
-client
|
||||
-config-file
|
||||
-config-dir
|
||||
-data-dir
|
||||
-recursor
|
||||
-dc
|
||||
-encrypt
|
||||
-join
|
||||
-join-wan
|
||||
-retry-join
|
||||
-retry-interval
|
||||
-retry-max-wan
|
||||
-log-level
|
||||
-node
|
||||
-protocol
|
||||
-rejoin
|
||||
-server
|
||||
-syslog
|
||||
-ui
|
||||
-ui-dir
|
||||
-pid-file
|
||||
"
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_configtest() {
|
||||
local subcommands="
|
||||
-config-file
|
||||
-config-dir
|
||||
"
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_event() {
|
||||
local subcommands="
|
||||
-http-addr
|
||||
-datacenter
|
||||
-name
|
||||
-node
|
||||
-service
|
||||
-tag
|
||||
-token
|
||||
"
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_exec() {
|
||||
local subcommands="
|
||||
-http-addr
|
||||
-datacenter
|
||||
-prefix
|
||||
-node
|
||||
-service
|
||||
-tag
|
||||
-wait
|
||||
-wait-repl
|
||||
-token
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_force_leave() {
|
||||
__consulcomp "-help -rpc-addr"
|
||||
}
|
||||
|
||||
__consul_info() {
|
||||
__consulcomp "-help -rpc-addr"
|
||||
}
|
||||
|
||||
__consul_join() {
|
||||
local subcommands="
|
||||
-rpc-addr
|
||||
-wan
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_keygen() {
|
||||
# NOTE: left empty on purpose.
|
||||
return
|
||||
}
|
||||
|
||||
__consul_keyring() {
|
||||
local subcommands="
|
||||
-install
|
||||
-list
|
||||
-remove
|
||||
-token
|
||||
-use
|
||||
-rpc-addr
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_leave() {
|
||||
__consulcomp "-help -rpc-addr"
|
||||
}
|
||||
|
||||
__consul_lock() {
|
||||
local subcommands="
|
||||
-http-addr
|
||||
-n
|
||||
-name
|
||||
-token
|
||||
-pass-stdin
|
||||
-try
|
||||
-monitor-retry
|
||||
-verbose
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_maint() {
|
||||
local subcommands="
|
||||
-enable
|
||||
-disable
|
||||
-reason
|
||||
-service
|
||||
-token
|
||||
-http-addr
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_members() {
|
||||
local subcommands="
|
||||
-detailed
|
||||
-rpc-addr
|
||||
-status
|
||||
-wan
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_monitor() {
|
||||
local subcommands="
|
||||
-log-level
|
||||
-rpc-addr
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_reload() {
|
||||
__consulcomp "-help -rpc-addr"
|
||||
}
|
||||
|
||||
__consul_rtt() {
|
||||
local subcommands="
|
||||
-wan
|
||||
-http-addr
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul_version() {
|
||||
# NOTE: left empty on purpose.
|
||||
return
|
||||
}
|
||||
|
||||
__consul_watch() {
|
||||
local subcommands="
|
||||
-http-addr
|
||||
-datacenter
|
||||
-token
|
||||
-key
|
||||
-name
|
||||
-passingonly
|
||||
-prefix
|
||||
-service
|
||||
-state
|
||||
-tag
|
||||
-type
|
||||
"
|
||||
|
||||
__consulcomp "-help $subcommands"
|
||||
}
|
||||
|
||||
__consul() {
|
||||
local c=1 command
|
||||
while [ $c -lt $COMP_CWORD ]; do
|
||||
cmd="${COMP_WORDS[c]}"
|
||||
case "$cmd" in
|
||||
-*) ;;
|
||||
*) command="$cmd"
|
||||
esac
|
||||
c=$((++c))
|
||||
done
|
||||
|
||||
local cmds="
|
||||
agent
|
||||
configtest
|
||||
event
|
||||
exec
|
||||
force-leave
|
||||
info
|
||||
join
|
||||
keygen
|
||||
keyring
|
||||
leave
|
||||
lock
|
||||
maint
|
||||
members
|
||||
monitor
|
||||
reload
|
||||
rtt
|
||||
version
|
||||
watch
|
||||
"
|
||||
|
||||
local globalflags="--help --version"
|
||||
|
||||
# Complete a command.
|
||||
if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
|
||||
case "${COMP_WORDS[COMP_CWORD]}" in
|
||||
-*|--*) __consulcomp "$globalflags" ;;
|
||||
*) __consulcomp "$cmds" ;;
|
||||
esac
|
||||
return
|
||||
fi
|
||||
|
||||
# Command options.
|
||||
local completion_func="__consul_${command//-/_}"
|
||||
declare -f $completion_func >/dev/null && $completion_func && return
|
||||
}
|
||||
|
||||
complete -o default -o nospace -F __consul consul
|
@ -1,5 +0,0 @@
|
||||
# Consul zsh completion
|
||||
|
||||
```bash
|
||||
./install.sh
|
||||
```
|
@ -1,178 +0,0 @@
|
||||
#compdef consul
|
||||
|
||||
local -a _1st_arguments
|
||||
_1st_arguments=(
|
||||
'agent:Runs a Consul agent'
|
||||
'event:Fire a new event'
|
||||
'exec:Executes a command on Consul nodes'
|
||||
'force-leave:Forces a member of the cluster to enter the "left" state'
|
||||
'info:Provides:debugging information for operators'
|
||||
'join:Tell Consul agent to join cluster'
|
||||
'keygen:Generates a new encryption key'
|
||||
'keyring:Manages gossip layer encryption keys'
|
||||
'leave:Gracefully leaves the Consul cluster and shuts down'
|
||||
'lock:Execute a command holding a lock'
|
||||
'maint:Controls node or service maintenance mode'
|
||||
'members:Lists the members of a Consul cluster'
|
||||
'monitor:Stream logs from a Consul agent'
|
||||
'reload:Triggers the agent to reload configuration files'
|
||||
'version:Prints the Consul version'
|
||||
'watch:Watch for changes in Consul'
|
||||
)
|
||||
|
||||
_arguments \
|
||||
'(--help)--help[Print help message]' \
|
||||
'(--version)--version[Print version]' \
|
||||
'*:: :->subcmds' && return 0
|
||||
|
||||
if (( CURRENT == 1 )); then
|
||||
_describe -t commands "consul subcommand" _1st_arguments
|
||||
return
|
||||
fi
|
||||
|
||||
__agent() {
|
||||
_arguments \
|
||||
'-advertise=[(addr) Sets the advertise address to use]' \
|
||||
'-bind=[(0.0.0.0) Sets the bind address for cluster communication]' \
|
||||
'-bootstrap-expect=[(0) Sets server to expect bootstrap mode]' \
|
||||
'-bootstrap[Sets server to bootstrap mode]' \
|
||||
'-client=[(127.0.0.1) Sets the address to bind for client access]' \
|
||||
'-config-dir=[(foo) Path to a directory to read configuration files from]' \
|
||||
'-config-file=[(foo) Path to a JSON file to read configuration from]' \
|
||||
'-data-dir=[(path) Path to a data directory to store agent state]' \
|
||||
'-dc=[(east-aws) Datacenter of the agent]' \
|
||||
'-dev[Starts the agent in development mode]' \
|
||||
'-encrypt=[(key) Provides the gossip encryption key]' \
|
||||
'-join=[(1.2.3.4) Address of an agent to join at start time]' \
|
||||
'-log-level=[(info) Log level of the agent]' \
|
||||
'-node=[(hostname) Name of this node. Must be unique in the cluster]' \
|
||||
'-pid-file=[(path) Path to file to store agent PID]' \
|
||||
'-protocol=[(N) Sets the protocol version. Defaults to latest]' \
|
||||
'-rejoin[Ignores a previous leave and attempts to rejoin the cluster]' \
|
||||
'-retry-interval=[(30s) Time to wait between join attempts]' \
|
||||
'-retry-join=[(1.2.3.4) Address of an agent to join at start time with retires enabled. Can be specified multiple times]' \
|
||||
'-retry-max=[(0) Maximum number of join attempts]' \
|
||||
'-server[Switches agent to server mode]' \
|
||||
'-syslog[Enables logging to syslog]' \
|
||||
'-ui-dir=[(path) Path to directory containing the Web UI resources]'
|
||||
}
|
||||
|
||||
__event() {
|
||||
_arguments \
|
||||
'-datacenter=[Datacenter to dispatch in]' \
|
||||
'-http-addr=[(127.0.0.1:8500) HTTP address of the Consul agent]' \
|
||||
'-name=[Name of the event]' \
|
||||
'-node=[Regular expression to filter on node names]' \
|
||||
'-service=[Regular expression to filter on service instances]' \
|
||||
'-tag=[Regular expression to filter on service tags. Must be used with -service]'
|
||||
}
|
||||
|
||||
__exec() {
|
||||
_arguments \
|
||||
'-datacenter=[Datacenter to dispatch in]' \
|
||||
'-http-addr=[(127.0.0.1:8500) HTTP address of the Consul agent]' \
|
||||
'-node=[Regular expression to filter on node names]' \
|
||||
'-prefix=[("_rexec") Prefix in the KV store to use for request data]' \
|
||||
'-service=[Regular expression to filter on service instances]' \
|
||||
'-tag=[Regular expression to filter on service tags. Must be used with -service]' \
|
||||
'-verbose[Enables verbose output]' \
|
||||
'-wait-repl=[(200ms) Perio to wait for replication before firing event. This is an optimization to allow stale reads to be performed]' \
|
||||
'-wait=[(2s) Period to wait with no responses before terminating execution]'
|
||||
}
|
||||
|
||||
__force-leave() {
|
||||
_arguments \
|
||||
'-rpc-addr=[(127.0.0.1:8500) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
__info() {
|
||||
_arguments \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
__join() {
|
||||
_arguments \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]' \
|
||||
'-wan[Joins a server to another server in the WAN pool]'
|
||||
}
|
||||
|
||||
__keyring() {
|
||||
_arguments \
|
||||
'-install=[(<key>) Install a new encryption key. This will broadcast the new key to all members in the cluster]' \
|
||||
'-use=[(key) Change the primary encryption key, which is used to encrypt messages. The key must already be installed before this operation can succeed]' \
|
||||
'-remove=[(key) Remove the given key from the cluster. This operation may only be performed on keys which are not currently the primary key]' \
|
||||
'-list=[(key) List all keys currently in use within the cluster]' \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
__leave() {
|
||||
_arguments \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
__lock() {
|
||||
_arguments \
|
||||
'-http-addr=[(127.0.0.1:8500) HTTP address of the Consul agent]' \
|
||||
'-n=[(1) Maximum number of allowed lock holders. If this value is one, it operates as a lock, otherwise a semaphore is used]' \
|
||||
'-name=[Optional name to associate with lock session]' \
|
||||
'-token=[ACL token to use. Defaults to that of agent]' \
|
||||
'-verbose[Enables verbose output]'
|
||||
}
|
||||
|
||||
__maint() {
|
||||
_arguments \
|
||||
'-enable[Enable maintenance mode]' \
|
||||
'-disable[Dsiable maintenance mode]' \
|
||||
'-reason=[(<string>) Text string describing the maintenance reason]' \
|
||||
'-service=[(<serviceID>) Control maintenance mode for a specific service ID]' \
|
||||
'-token=[ACL token to use. Defaults to that of agent]' \
|
||||
'-http-addr=[(127.0.0.1:8500) HTTP address of the Consul agent]'
|
||||
}
|
||||
|
||||
__members() {
|
||||
_arguments \
|
||||
'-detailed[Provides detailed information about nodes]' \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]' \
|
||||
'-status=[(<regexp>) If provided, output is filtered to only nodes matching the regular expression for status]' \
|
||||
'-wan[If the agent is in server mode, this can be used to return other peers in the WAN pool]'
|
||||
}
|
||||
|
||||
__monitor() {
|
||||
_arguments \
|
||||
'-log-level=[(info) Log level of the agent]' \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
__reload() {
|
||||
_arguments \
|
||||
'-rpc-addr=[(127.0.0.1:8400) RPC address of the Consul agent]'
|
||||
}
|
||||
|
||||
case "$words[1]" in
|
||||
agent)
|
||||
__agent ;;
|
||||
event)
|
||||
__event ;;
|
||||
exec)
|
||||
__exec ;;
|
||||
force-leave)
|
||||
__force-leave ;;
|
||||
info)
|
||||
__info ;;
|
||||
join)
|
||||
__join ;;
|
||||
keyring)
|
||||
__keyring ;;
|
||||
leave)
|
||||
__leave ;;
|
||||
lock)
|
||||
__lock ;;
|
||||
maint)
|
||||
__maint ;;
|
||||
members)
|
||||
__members ;;
|
||||
monitor)
|
||||
__monitor ;;
|
||||
reload)
|
||||
__reload ;;
|
||||
esac
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
ZSH_FUNC_DIR="/usr/share/zsh/site-functions"
|
||||
|
||||
if [ -d "$ZSH_FUNC_DIR" ]; then
|
||||
echo "Installing into ${ZSH_FUNC_DIR}..."
|
||||
sudo cp ./_consul "$ZSH_FUNC_DIR"
|
||||
echo "Installed! Make sure that ${ZSH_FUNC_DIR} is in your \$fpath."
|
||||
else
|
||||
echo "Could not find ${ZSH_FUNC_DIR}. Please install manually."
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in new issue