mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 09:02:00 +00:00
44 lines
1.2 KiB
Plaintext
44 lines
1.2 KiB
Plaintext
[[ -v $_CLICKHOUSE_COMPLETION_LOADED ]] || source "$(dirname "${BASH_SOURCE[0]}")/clickhouse-bootstrap"
|
|
|
|
function _clickhouse_get_utils()
|
|
{
|
|
local cmd=$1 && shift
|
|
"$cmd" --help |& awk '/^clickhouse.*args/ { print $2 }'
|
|
}
|
|
|
|
function _complete_for_clickhouse_entrypoint_bin()
|
|
{
|
|
local cur prev cword words
|
|
eval local cmd="$( _clickhouse_quote "$1" )"
|
|
_clickhouse_bin_exist "$cmd" || return 0
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev cword words
|
|
|
|
local util="$cur"
|
|
# complete utils, until it will be finished
|
|
if [[ $cword -lt 2 ]]; then
|
|
COMPREPLY=( $(compgen -W "$(_clickhouse_get_utils "$cmd")" -- "$cur") )
|
|
return
|
|
fi
|
|
util="${words[1]}"
|
|
|
|
case "$prev" in
|
|
-C|--config-file|--config)
|
|
return
|
|
;;
|
|
# Argh... This looks like a bash bug...
|
|
# Redirections are passed to the completion function
|
|
# although it is managed by the shell directly...
|
|
'<'|'>'|'>>'|[12]'>'|[12]'>>')
|
|
return
|
|
;;
|
|
esac
|
|
|
|
COMPREPLY=( $(compgen -W "$(_clickhouse_get_options "$cmd" "$util")" -- "$cur") )
|
|
|
|
return 0
|
|
}
|
|
|
|
_complete_clickhouse_generic clickhouse _complete_for_clickhouse_entrypoint_bin
|