mirror of
https://github.com/hanzoai/datastore.git
synced 2026-09-26 13:55:07 +00:00
The prior sweep kept " in the exclusion set to guard the SQL keyword "clickhouse", which
over-protected ALL quoted display strings ("clickhouse " << app in --help, install-tool defaults
like DEFAULT_..._SERVER_USER="clickhouse"/getpwnam("clickhouse")/binary-name fallbacks). Redid the
pass dropping " from the exclusion while still skipping the 4 SQL dict-source keyword lines, URLs,
and /clickhouse + .clickhouse.hash paths (kept . / - in the boundary). Renamed the 2 fuzzer files
clickhouse_fuzzer.cpp / clickhouse-template.g (not built; completeness).
Remaining lowercase clickhouse (526) = URLs, SQL SOURCE(CLICKHOUSE) keyword, and ZK/fs path
conventions (/var/lib/clickhouse, /clickhouse/tables) + internal .clickhouse.hash ELF section —
all protocol/external/convention, intentionally kept.
255 lines
6.0 KiB
Plaintext
255 lines
6.0 KiB
Plaintext
#
|
|
# 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 _DATASTORE_COMPLETION_LOADED=1
|
|
|
|
DATASTORE_logs_level=(
|
|
none
|
|
fatal
|
|
error
|
|
warning
|
|
information
|
|
debug
|
|
trace
|
|
test
|
|
)
|
|
|
|
DATASTORE_QueryProcessingStage=(
|
|
complete
|
|
fetch_columns
|
|
with_mergeable_state
|
|
with_mergeable_state_after_aggregation
|
|
with_mergeable_state_after_aggregation_and_limit
|
|
)
|
|
|
|
DATASTORE_QueryKind=(
|
|
initial_query
|
|
secondary_query
|
|
no_query
|
|
)
|
|
|
|
# SELECT name FROM system.formats ORDER BY name FORMAT LineAsString
|
|
DATASTORE_Format=(
|
|
Arrow
|
|
ArrowStream
|
|
Avro
|
|
AvroConfluent
|
|
BSONEachRow
|
|
CSV
|
|
CSVWithNames
|
|
CSVWithNamesAndTypes
|
|
CapnProto
|
|
CustomSeparated
|
|
CustomSeparatedIgnoreSpaces
|
|
CustomSeparatedIgnoreSpacesWithNames
|
|
CustomSeparatedIgnoreSpacesWithNamesAndTypes
|
|
CustomSeparatedWithNames
|
|
CustomSeparatedWithNamesAndTypes
|
|
DWARF
|
|
HiveText
|
|
JSON
|
|
JSONAsObject
|
|
JSONAsString
|
|
JSONColumns
|
|
JSONColumnsWithMetadata
|
|
JSONCompact
|
|
JSONCompactColumns
|
|
JSONCompactEachRow
|
|
JSONCompactEachRowWithNames
|
|
JSONCompactEachRowWithNamesAndTypes
|
|
JSONCompactStrings
|
|
JSONCompactStringsEachRow
|
|
JSONCompactStringsEachRowWithNames
|
|
JSONCompactStringsEachRowWithNamesAndTypes
|
|
JSONEachRow
|
|
JSONEachRowWithProgress
|
|
JSONLines
|
|
JSONObjectEachRow
|
|
JSONStrings
|
|
JSONStringsEachRow
|
|
JSONStringsEachRowWithProgress
|
|
LineAsString
|
|
LineAsStringWithNames
|
|
LineAsStringWithNamesAndTypes
|
|
Markdown
|
|
MsgPack
|
|
MySQLDump
|
|
MySQLWire
|
|
NDJSON
|
|
Native
|
|
Null
|
|
ODBCDriver2
|
|
ORC
|
|
One
|
|
Parquet
|
|
ParquetMetadata
|
|
PostgreSQLWire
|
|
Pretty
|
|
PrettyCompact
|
|
PrettyCompactMonoBlock
|
|
PrettyCompactNoEscapes
|
|
PrettyCompactNoEscapesMonoBlock
|
|
PrettyJSONEachRow
|
|
PrettyJSONLines
|
|
PrettyMonoBlock
|
|
PrettyNDJSON
|
|
PrettyNoEscapes
|
|
PrettyNoEscapesMonoBlock
|
|
PrettySpace
|
|
PrettySpaceMonoBlock
|
|
PrettySpaceNoEscapes
|
|
PrettySpaceNoEscapesMonoBlock
|
|
Prometheus
|
|
Protobuf
|
|
ProtobufList
|
|
ProtobufSingle
|
|
RawBLOB
|
|
Regexp
|
|
RowBinary
|
|
RowBinaryWithDefaults
|
|
RowBinaryWithNames
|
|
RowBinaryWithNamesAndTypes
|
|
SQLInsert
|
|
TSKV
|
|
TSV
|
|
TSVRaw
|
|
TSVRawWithNames
|
|
TSVRawWithNamesAndTypes
|
|
TSVWithNames
|
|
TSVWithNamesAndTypes
|
|
TabSeparated
|
|
TabSeparatedRaw
|
|
TabSeparatedRawWithNames
|
|
TabSeparatedRawWithNamesAndTypes
|
|
TabSeparatedWithNames
|
|
TabSeparatedWithNamesAndTypes
|
|
Template
|
|
TemplateIgnoreSpaces
|
|
Values
|
|
Vertical
|
|
XML
|
|
)
|
|
|
|
function _datastore_bin_exist()
|
|
{ [ -x "$1" ] || command -v "$1" >& /dev/null; }
|
|
|
|
function _datastore_quote()
|
|
{
|
|
local quoted=${1//\'/\'\\\'\'};
|
|
printf "'%s'" "$quoted"
|
|
}
|
|
|
|
# Extract every option (everything that starts with "-") from the --help dialog.
|
|
function _datastore_get_options()
|
|
{
|
|
local extra_args=()
|
|
|
|
local command_base="${1/*\/}"
|
|
# Some tools like client/local/benchmark --help will not print all settings, this is done only under --verbose
|
|
case "$command_base" in
|
|
chc|datastore-client) extra_args+=(--verbose) ;;
|
|
ch|datastore-local) extra_args+=(--verbose) ;;
|
|
datastore-benchmark) extra_args+=(--verbose) ;;
|
|
esac
|
|
if [ "$command_base" = "datastore" ]; then
|
|
case "$2" in
|
|
client) extra_args+=(--verbose) ;;
|
|
local) extra_args+=(--verbose) ;;
|
|
benchmark) extra_args+=(--verbose) ;;
|
|
esac
|
|
fi
|
|
|
|
"$@" --help "${extra_args[@]}" 2>&1 | LANG=c awk -F '[ ,=<>.]' '{ for (i=1; i <= NF; ++i) { if (substr($i, 1, 1) == "-" && length($i) > 1) print $i; } }' | sort -u
|
|
}
|
|
|
|
function _complete_for_datastore_generic_bin_impl()
|
|
{
|
|
local prev=$1 && shift
|
|
|
|
case "$prev" in
|
|
-C|--config-file|--config)
|
|
return 1
|
|
;;
|
|
--stage)
|
|
COMPREPLY=( $(compgen -W "${DATASTORE_QueryProcessingStage[*]}" -- "$cur") )
|
|
return 1
|
|
;;
|
|
--query_kind)
|
|
COMPREPLY=( $(compgen -W "${DATASTORE_QueryKind[*]}" -- "$cur") )
|
|
return 1
|
|
;;
|
|
--send_logs_level)
|
|
COMPREPLY=( $(compgen -W "${DATASTORE_logs_level[*]}" -- "$cur") )
|
|
return 1
|
|
;;
|
|
--format|--input-format|--output-format)
|
|
COMPREPLY=( $(compgen -W "${DATASTORE_Format[*]}" -- "$cur") )
|
|
return 1
|
|
;;
|
|
--host)
|
|
COMPREPLY=( $(compgen -A hostname -- "$cur") )
|
|
return 1
|
|
;;
|
|
# 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 1
|
|
;;
|
|
esac
|
|
|
|
return 0
|
|
}
|
|
|
|
function _complete_for_datastore_generic_bin()
|
|
{
|
|
local cur prev
|
|
eval local cmd="$( _datastore_quote "$1" )"
|
|
_datastore_bin_exist "$cmd" || return 0
|
|
|
|
COMPREPLY=()
|
|
_get_comp_words_by_ref cur prev
|
|
|
|
if _complete_for_datastore_generic_bin_impl "$prev"; then
|
|
COMPREPLY=( $(compgen -W "$(_datastore_get_options "$cmd")" -- "$cur") )
|
|
fi
|
|
|
|
return 0
|
|
}
|
|
|
|
function _complete_datastore_generic()
|
|
{
|
|
local bin=$1 && shift
|
|
local f=${1:-_complete_for_datastore_generic_bin}
|
|
local o=(
|
|
-o default
|
|
-o bashdefault
|
|
-o nospace
|
|
-F "$f"
|
|
"$bin"
|
|
)
|
|
complete "${o[@]}"
|
|
}
|
|
|
|
function _complete_datastore_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_datastore_bootstrap_main "$@"
|