diff --git a/completions/Makefile.am b/completions/Makefile.am index a7ad5edf..62d6188c 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -127,6 +127,7 @@ bashcomp_DATA = abook \ postgresql \ povray \ procps \ + protoc \ puppet \ python \ qdbus \ diff --git a/completions/protoc b/completions/protoc new file mode 100644 index 00000000..26a10961 --- /dev/null +++ b/completions/protoc @@ -0,0 +1,69 @@ +have protoc || return + +_protoc() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + --proto_path|--cpp_out|--java_out|--python_out) + _filedir -d + return + ;; + --version|-h|--help|--encode|--decode) + return + ;; + --descriptor_set_out) + _filedir + return + ;; + --error_format) + COMPREPLY=( $( compgen -W 'gcc msvs' -- "$cur" ) ) + return + ;; + --plugin) + if [[ $cur != *=* ]]; then + compopt -o filenames + COMPREPLY=( $( compgen -c -- "$cur" ) ) + fi + return + ;; + esac + + $split && return + + case $cur in + -o*) + cur=${cur:2} + _filedir + COMPREPLY=( "${COMPREPLY[@]/#/-o}" ) + return + ;; + -I*) + cur=${cur:2} + _filedir -d + COMPREPLY=( "${COMPREPLY[@]/#/-I}" ) + return + ;; + -*) + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + local i + for i in ${!COMPREPLY[@]}; do + [[ ${COMPREPLY[i]} == -oFILE ]] && unset COMPREPLY[i] + done + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + ;; + esac + + _filedir proto +} && +complete -F _protoc protoc + +# Local variables: +# mode: shell-script +# sh-basic-offset: 4 +# sh-indent-comment: t +# indent-tabs-mode: nil +# End: +# ex: ts=4 sw=4 et filetype=sh diff --git a/test/completion/protoc.exp b/test/completion/protoc.exp new file mode 100644 index 00000000..333ebf26 --- /dev/null +++ b/test/completion/protoc.exp @@ -0,0 +1 @@ +assert_source_completions protoc diff --git a/test/lib/completions/protoc.exp b/test/lib/completions/protoc.exp new file mode 100644 index 00000000..caeb8274 --- /dev/null +++ b/test/lib/completions/protoc.exp @@ -0,0 +1,20 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "protoc " + + +sync_after_int + + +teardown