# bash completion for sysbench -*- shell-script -*- proc _sysbench { local cur prev words cword split _init_completion -s || return match $prev { with --num-threads|--max-requests|--max-time|--thread-stack-size| \ --help|--version|help|version return 0 with --init-rng|--debug|--validate setglobal COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) return 0 with --test setglobal COMPREPLY = ''( $( compgen -W 'fileio cpu memory threads mutex oltp' \ -- "$cur" ) ) return 0 with --cpu-max-prime return 0 with --file-test-mode setglobal COMPREPLY = ''( $( compgen -W 'seqwr seqrewr seqrd rndrd rndwr rndrw' \ -- "$cur" ) ) return 0 with --file-io-mode setglobal COMPREPLY = ''( $( compgen -W 'sync async fastmmap slowmmap' \ -- "$cur" ) ) return 0 with --file-extra-flags setglobal COMPREPLY = ''( $( compgen -W 'sync dsync direct' -- "$cur" ) ) return 0 with --file-fsync-all|--file-fsync-end setglobal COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) return 0 with --file-fsync-mode setglobal COMPREPLY = ''( $( compgen -W 'fsync fdatasync' -- "$cur" ) ) return 0 with --memory-scope setglobal COMPREPLY = ''( $( compgen -W 'global local' -- "$cur" ) ) return 0 with --memory-hugetlb setglobal COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) return 0 with --memory-oper setglobal COMPREPLY = ''( $( compgen -W 'read write none' -- "$cur" ) ) return 0 with --memory-access-mode setglobal COMPREPLY = ''( $( compgen -W 'seq rnd' -- "$cur" ) ) return 0 with --oltp-test-mode setglobal COMPREPLY = ''( $( compgen -W 'simple complex nontrx sp' -- "$cur" ) ) return 0 with --oltp-read-only|--oltp-skip-trx|--oltp-quto-inc|--mysql-ssl setglobal COMPREPLY = ''( $( compgen -W 'on off' -- "$cur" ) ) return 0 with --oltp-nontrx-mode setglobal COMPREPLY = ''( $( compgen -W 'select update_key update_nokey insert delete' -- "$cur" ) ) return 0 with --oltp-dist-type setglobal COMPREPLY = ''( $( compgen -W 'uniform gaussian special' -- "$cur" ) ) return 0 with --db-driver setglobal COMPREPLY = ''( $( compgen -W "$( $1 --test=oltp help 2>/dev/null | sed -e '/^.*database drivers:/,/^$/!d' \ -ne 's/^ *\([^ ]*\) .*/\1/p' )" -- "$cur" ) ) return 0 with --db-ps-mode setglobal COMPREPLY = ''( $( compgen -W 'auto disable' -- "$cur" ) ) return 0 with --mysql-socket _filedir sock return 0 with --mysql-table-engine setglobal COMPREPLY = ''( $( compgen -W 'myisam innodb bdb heap ndbcluster federated' -- "$cur" ) ) return 0 with --mysql-engine-trx setglobal COMPREPLY = ''( $( compgen -W 'yes no auto' -- "$cur" ) ) return 0 with --* $split && return 0 } # find out which test we're running local i test for (( i=1 ; $i < ${#words[@]}-1 ; i++ )); do if [[ ${words[i]} == --test* ]]; then test=${words[i]#*=} break fi done local opts=$[ _parse_help $1] if [[ $test ]] { local help=( $( _parse_help "$1" "--test=$test help" ) ) setglobal opts = ""$(opts[@]/--test=/) $(help[@]) prepare run cleanup help version"" } if [[ "$cur" == -* || ! $test ]] { setglobal COMPREPLY = ''( $( compgen -W "$opts" -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } else { setglobal COMPREPLY = ''( $( compgen -W "prepare run cleanup help version" \ -- "$cur" ) ) } } && complete -F _sysbench sysbench # ex: ts=4 sw=4 et filetype=sh