diff options
Diffstat (limited to '')
-rw-r--r-- | completions/sysbench | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/completions/sysbench b/completions/sysbench index 0af7cc3..7f9e87e 100644 --- a/completions/sysbench +++ b/completions/sysbench @@ -1,9 +1,9 @@ # bash completion for sysbench -*- shell-script -*- -_sysbench() +_comp_cmd_sysbench() { - local cur prev words cword split - _init_completion -s || return + local cur prev words cword was_split comp_args + _comp_initialize -s -- "$@" || return case $prev in --num-threads | --max-requests | --max-time | --thread-stack-size | \ @@ -11,122 +11,121 @@ _sysbench() return ;; --init-rng | --debug | --validate) - COMPREPLY=($(compgen -W 'on off' -- "$cur")) + _comp_compgen -- -W 'on off' return ;; --test) - COMPREPLY=($(compgen -W 'fileio cpu memory threads mutex oltp' \ - -- "$cur")) + _comp_compgen -- -W 'fileio cpu memory threads mutex oltp' return ;; --cpu-max-prime) return ;; --file-test-mode) - COMPREPLY=($(compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ - -- "$cur")) + _comp_compgen -- -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' return ;; --file-io-mode) - COMPREPLY=($(compgen -W 'sync async fastmmap slowmmap' -- "$cur")) + _comp_compgen -- -W 'sync async fastmmap slowmmap' return ;; --file-extra-flags) - COMPREPLY=($(compgen -W 'sync dsync direct' -- "$cur")) + _comp_compgen -- -W 'sync dsync direct' return ;; --file-fsync-all | --file-fsync-end) - COMPREPLY=($(compgen -W 'on off' -- "$cur")) + _comp_compgen -- -W 'on off' return ;; --file-fsync-mode) - COMPREPLY=($(compgen -W 'fsync fdatasync' -- "$cur")) + _comp_compgen -- -W 'fsync fdatasync' return ;; --memory-scope) - COMPREPLY=($(compgen -W 'global local' -- "$cur")) + _comp_compgen -- -W 'global local' return ;; --memory-hugetlb) - COMPREPLY=($(compgen -W 'on off' -- "$cur")) + _comp_compgen -- -W 'on off' return ;; --memory-oper) - COMPREPLY=($(compgen -W 'read write none' -- "$cur")) + _comp_compgen -- -W 'read write none' return ;; --memory-access-mode) - COMPREPLY=($(compgen -W 'seq rnd' -- "$cur")) + _comp_compgen -- -W 'seq rnd' return ;; --oltp-test-mode) - COMPREPLY=($(compgen -W 'simple complex nontrx sp' -- "$cur")) + _comp_compgen -- -W 'simple complex nontrx sp' return ;; --oltp-read-only | --oltp-skip-trx | --oltp-quto-inc | --mysql-ssl) - COMPREPLY=($(compgen -W 'on off' -- "$cur")) + _comp_compgen -- -W 'on off' return ;; --oltp-nontrx-mode) - COMPREPLY=($(compgen -W 'select update_key update_nokey insert - delete' -- "$cur")) + _comp_compgen -- -W 'select update_key update_nokey insert delete' return ;; --oltp-dist-type) - COMPREPLY=($(compgen -W 'uniform gaussian special' -- "$cur")) + _comp_compgen -- -W 'uniform gaussian special' return ;; --db-driver) - COMPREPLY=($(compgen -W "$($1 --test=oltp help 2>/dev/null | + _comp_compgen_split -- "$("$1" --test=oltp help 2>/dev/null | command sed -e '/^.*database drivers:/,/^$/!d' \ - -ne 's/^ *\([^ ]*\) .*/\1/p')" -- "$cur")) + -ne 's/^ *\([^ ]*\) .*/\1/p')" return ;; --db-ps-mode) - COMPREPLY=($(compgen -W 'auto disable' -- "$cur")) + _comp_compgen -- -W 'auto disable' return ;; --mysql-socket) - _filedir sock + _comp_compgen_filedir sock return ;; --mysql-table-engine) - COMPREPLY=($(compgen -W 'myisam innodb bdb heap ndbcluster - federated' -- "$cur")) + _comp_compgen -- -W 'myisam innodb bdb heap ndbcluster federated' return ;; --mysql-engine-trx) - COMPREPLY=($(compgen -W 'yes no auto' -- "$cur")) + _comp_compgen -- -W 'yes no auto' return ;; --*) - $split && return + [[ $was_split ]] && return ;; esac # find out which test we're running - local i test + local i test="" has_test="" for ((i = 1; i < ${#words[@]} - 1; i++)); do # TODO --test= is deprecated, bare test name preferred - if [[ ${words[i]} == --test* ]]; then + if [[ ${words[i]} == --test=* ]]; then test=${words[i]#*=} + has_test=set break fi done - local opts=$(_parse_help "$1") - if [[ -v test ]]; then - local help=($(_parse_help "$1" "--test=$test help")) - opts="${opts/--test=/} ${help[*]} prepare run cleanup help version" + local opts + _comp_compgen -v opts help + if [[ $has_test ]]; then + opts=("${opts[@]/#--test=/}") + _comp_compgen -aRv opts help -- --test="$test" help + opts+=(prepare run cleanup help version) fi - if [[ $cur == -* || ! -v test ]]; then - COMPREPLY=($(compgen -W "$opts" -- "$cur")) + if [[ $cur == -* || ! $has_test ]]; then + _comp_compgen -- -W '"${opts[@]}"' [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - COMPREPLY=($(compgen -W "prepare run cleanup help version" -- "$cur")) + _comp_compgen -- -W "prepare run cleanup help version" fi } && - complete -F _sysbench sysbench + complete -F _comp_cmd_sysbench sysbench # ex: filetype=sh |