# bash completion for cppcheck(1) -*- shell-script -*- proc _cppcheck { var cur = '', prev = '', words = '', cword = '', split = '' _init_completion -s || return match $prev { with --append|--exitcode-suppressions|--rule-file|--config-excludes-file|\ --suppressions-list|--includes-file|--include|-i _filedir return with -D|-U|--rule|--suppress|--template|--max-configs|-h|--help|--version|\ --errorlist|--config-exclude|-l return with --enable # split comma-separated list set split = 'false' if [[ "$cur" == ?*,* ]] { set prev = $(cur%,*) set cur = $(cur##*,) set split = 'true' } setglobal COMPREPLY = '( '$( compgen -W 'all warning style performance portability information unusedFunction missingInclude' \ -- "$cur" ) ) $split && setglobal COMPREPLY = '( '${COMPREPLY[@]/#/"$prev,"} ) return with --error-exitcode setglobal COMPREPLY = '( '$( compgen -W '{0..255}' -- "$cur" ) ) return with --file-list _filedir [[ -z $cur || $cur == - ]] && setglobal COMPREPLY = '( '- ) return with -I _filedir -d return with -j setglobal COMPREPLY = '( '$( compgen -W "{2..$(_ncpus)}" -- "$cur" ) ) return with --language|-x setglobal COMPREPLY = '( '$( compgen -W 'c c++' -- "$cur" ) ) return with --std setglobal COMPREPLY = '( '$( compgen -W 'c89 c99 c11 c++03 c++11 posix' \ -- "$cur" ) ) return with --platform setglobal COMPREPLY = '( '$( compgen -W 'unix32 unix64 win32A win32W win64 native' -- "$cur" ) ) return with -rp|--relative-paths if $split { # -rp without argument is allowed _filedir -d return } with --library _filedir cfg return with --xml-version setglobal COMPREPLY = '( '$( compgen -W '1 2' -- "$cur" ) ) return } $split && return if [[ $cur == -* ]] { setglobal COMPREPLY = '( '$( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) [[ $COMPREPLY == *= ]] && compopt -o nospace } else { _filedir '@([cht]pp|[cht]xx|cc|[ch]++|[ch])' } } && complete -F _cppcheck cppcheck # ex: ts=4 sw=4 et filetype=sh