diff options
Diffstat (limited to 'completions/cppcheck')
-rw-r--r-- | completions/cppcheck | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/completions/cppcheck b/completions/cppcheck index 8ea9571..5867fc7 100644 --- a/completions/cppcheck +++ b/completions/cppcheck @@ -1,14 +1,14 @@ # bash completion for cppcheck(1) -*- shell-script -*- -_cppcheck() +_comp_cmd_cppcheck() { - 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 --append | --exitcode-suppressions | --rule-file | --config-excludes-file | \ --suppressions-list | --includes-file | --include | -i) - _filedir + _comp_compgen_filedir return ;; -D | -U | --rule | --suppress | --template | --max-configs | -h | --help | --version | \ @@ -17,75 +17,75 @@ _cppcheck() ;; --enable) # split comma-separated list - split=false + local split="" if [[ $cur == ?*,* ]]; then prev="${cur%,*}" cur="${cur##*,}" - split=true + split="set" fi - COMPREPLY=($(compgen -W 'all warning style performance - portability information unusedFunction missingInclude' \ - -- "$cur")) - $split && COMPREPLY=(${COMPREPLY[@]/#/"$prev,"}) + _comp_compgen -- -W 'all warning style performance portability + information unusedFunction missingInclude' && + [[ $split ]] && + _comp_compgen -Rv COMPREPLY -- -P "$prev," -W '"${COMPREPLY[@]}"' return ;; --error-exitcode) - COMPREPLY=($(compgen -W '{0..255}' -- "$cur")) + _comp_compgen -- -W '{0..255}' return ;; --file-list) - _filedir - [[ -z $cur || $cur == - ]] && COMPREPLY+=(-) + _comp_compgen_filedir + [[ ! $cur || $cur == - ]] && COMPREPLY+=(-) return ;; -I) - _filedir -d + _comp_compgen_filedir -d return ;; -j) - COMPREPLY=($(compgen -W "{2..$(_ncpus)}" -- "$cur")) + local REPLY + _comp_get_ncpus + _comp_compgen -- -W "{1..$REPLY}" return ;; --language | -x) - COMPREPLY=($(compgen -W 'c c++' -- "$cur")) + _comp_compgen -- -W 'c c++' return ;; --std) - COMPREPLY=($(compgen -W 'c89 c99 c11 c++03 c++11 c++14 c++17 - c++20' -- "$cur")) + _comp_compgen -- -W 'c89 c99 c11 c++03 c++11 c++14 c++17 c++20' return ;; --platform) - _filedir - COMPREPLY+=($(compgen -W 'unix32 unix64 win32A win32W win64 - native' -- "$cur")) + _comp_compgen_filedir + _comp_compgen -a -- -W 'unix32 unix64 win32A win32W win64 native' return ;; -rp | --relative-paths) - if $split; then # -rp without argument is allowed - _filedir -d + if [[ $was_split ]]; then # -rp without argument is allowed + _comp_compgen_filedir -d return fi ;; --library) - _filedir cfg + _comp_compgen_filedir cfg return ;; --xml-version) - COMPREPLY=($(compgen -W '1 2' -- "$cur")) + _comp_compgen -- -W '1 2' return ;; esac - $split && return + [[ $was_split ]] && return if [[ $cur == -* ]]; then - COMPREPLY=($(compgen -W '$(_parse_help "$1")' -- "$cur")) + _comp_compgen_help [[ ${COMPREPLY-} == *= ]] && compopt -o nospace else - _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' + _comp_compgen_filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' fi } && - complete -F _cppcheck cppcheck + complete -F _comp_cmd_cppcheck cppcheck # ex: filetype=sh |