Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
2dot5
ClickHouse
提交
6a7d873e
C
ClickHouse
项目概览
2dot5
/
ClickHouse
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
ClickHouse
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
6a7d873e
编写于
3月 22, 2021
作者:
A
Alexander Kuzmenkov
提交者:
GitHub
3月 22, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #21853 from azat/bash-completion
Add bash completion support for clickhouse utils
上级
231c7266
84280f11
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
161 addition
and
0 deletion
+161
-0
debian/clickhouse-common-static.install
debian/clickhouse-common-static.install
+1
-0
programs/CMakeLists.txt
programs/CMakeLists.txt
+1
-0
programs/bash-completion/CMakeLists.txt
programs/bash-completion/CMakeLists.txt
+1
-0
programs/bash-completion/completions/CMakeLists.txt
programs/bash-completion/completions/CMakeLists.txt
+28
-0
programs/bash-completion/completions/clickhouse
programs/bash-completion/completions/clickhouse
+43
-0
programs/bash-completion/completions/clickhouse-benchmark
programs/bash-completion/completions/clickhouse-benchmark
+2
-0
programs/bash-completion/completions/clickhouse-bootstrap
programs/bash-completion/completions/clickhouse-bootstrap
+81
-0
programs/bash-completion/completions/clickhouse-client
programs/bash-completion/completions/clickhouse-client
+2
-0
programs/bash-completion/completions/clickhouse-local
programs/bash-completion/completions/clickhouse-local
+2
-0
未找到文件。
debian/clickhouse-common-static.install
浏览文件 @
6a7d873e
usr
/
bin
/
clickhouse
usr
/
bin
/
clickhouse
-
odbc
-
bridge
usr
/
bin
/
clickhouse
-
extract
-
from
-
config
usr
/
share
/
bash
-
completion
/
completions
etc
/
security
/
limits
.
d
/
clickhouse
.
conf
programs/CMakeLists.txt
浏览文件 @
6a7d873e
...
...
@@ -188,6 +188,7 @@ add_subdirectory (format)
add_subdirectory
(
obfuscator
)
add_subdirectory
(
install
)
add_subdirectory
(
git-import
)
add_subdirectory
(
bash-completion
)
if
(
ENABLE_CLICKHOUSE_ODBC_BRIDGE
)
add_subdirectory
(
odbc-bridge
)
...
...
programs/bash-completion/CMakeLists.txt
0 → 100644
浏览文件 @
6a7d873e
add_subdirectory
(
completions
)
programs/bash-completion/completions/CMakeLists.txt
0 → 100644
浏览文件 @
6a7d873e
macro
(
configure_bash_completion
)
set
(
out
"/usr/share/bash-completion/completions"
)
find_program
(
pkg-config PKG_CONFIG_BIN
)
if
(
PKG_CONFIG_BIN
)
execute_process
(
COMMAND
${
PKG_CONFIG_BIN
}
--variable=completionsdir bash-completion
OUTPUT_VARIABLE
${
out
}
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif
()
string
(
REPLACE /usr
"
${
CMAKE_INSTALL_PREFIX
}
"
out
"
${
out
}
"
)
message
(
STATUS
"bash_completion will be written to
${
out
}
"
)
endmacro
()
configure_bash_completion
()
foreach
(
name
# set of functions
clickhouse-bootstrap
# binaries that accept settings as command line argument
clickhouse-client
clickhouse-local
clickhouse-benchmark
clickhouse
)
install
(
FILES
${
name
}
DESTINATION
${
out
}
)
endforeach
()
programs/bash-completion/completions/clickhouse
0 → 100644
浏览文件 @
6a7d873e
[[ -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
programs/bash-completion/completions/clickhouse-benchmark
0 → 100644
浏览文件 @
6a7d873e
[[ -v $_CLICKHOUSE_COMPLETION_LOADED ]] || source "$(dirname "${BASH_SOURCE[0]}")/clickhouse-bootstrap"
_complete_clickhouse_generic clickhouse-benchmark
programs/bash-completion/completions/clickhouse-bootstrap
0 → 100644
浏览文件 @
6a7d873e
#
# bash autocomplete, that can work with:
# a) --help of program
#
# Also you may like:
# $ bind "set completion-ignore-case on"
# $ bind "set show-all-if-ambiguous on"
#
# It uses bash-completion dynamic loader.
# Known to work with bash 3.* with programmable completion and extended
# pattern matching enabled (use 'shopt -s extglob progcomp' to enable
# these if they are not already enabled).
shopt -s extglob
export _CLICKHOUSE_COMPLETION_LOADED=1
function _clickhouse_bin_exist()
{ [ -x "$1" ] || command -v "$1" >& /dev/null; }
function _clickhouse_quote()
{
local quoted=${1//\'/\'\\\'\'};
printf "'%s'" "$quoted"
}
# Extract every option (everything that starts with "-") from the --help dialog.
function _clickhouse_get_options()
{
"$@" --help 2>&1 | awk -F '[ ,=<>]' '{ for (i=1; i <= NF; ++i) { if (substr($i, 0, 1) == "-" && length($i) > 1) print $i; } }' | sort -u
}
function _complete_for_clickhouse_generic_bin()
{
local cur prev
eval local cmd="$( _clickhouse_quote "$1" )"
_clickhouse_bin_exist "$cmd" || return 0
COMPREPLY=()
_get_comp_words_by_ref cur prev
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")" -- "$cur") )
return 0
}
function _complete_clickhouse_generic()
{
local bin=$1 && shift
local f=${1:-_complete_for_clickhouse_generic_bin}
local o=(
-o default
-o bashdefault
-o nospace
-F "$f"
"$bin"
)
complete "${o[@]}"
}
function _complete_clickhouse_bootstrap_main()
{
local runtime=/usr/share/bash-completion/bash_completion
if ! type _get_comp_words_by_ref >& /dev/null && [[ -f $runtime ]]; then
source $runtime
fi
type _get_comp_words_by_ref >& /dev/null || return 0
}
_complete_clickhouse_bootstrap_main "$@"
programs/bash-completion/completions/clickhouse-client
0 → 100644
浏览文件 @
6a7d873e
[[ -v $_CLICKHOUSE_COMPLETION_LOADED ]] || source "$(dirname "${BASH_SOURCE[0]}")/clickhouse-bootstrap"
_complete_clickhouse_generic clickhouse-client
programs/bash-completion/completions/clickhouse-local
0 → 100644
浏览文件 @
6a7d873e
[[ -v $_CLICKHOUSE_COMPLETION_LOADED ]] || source "$(dirname "${BASH_SOURCE[0]}")/clickhouse-bootstrap"
_complete_clickhouse_generic clickhouse-local
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录