diff --git a/completions/2to3 b/completions/2to3 new file mode 100644 index 00000000..a977f20e --- /dev/null +++ b/completions/2to3 @@ -0,0 +1,39 @@ +# bash completion for 2to3 -*- shell-script -*- + +_2to3() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -h|--help|--add-suffix) + return + ;; + -f|--fix|-x|--nofix) + COMPREPLY=( $( compgen -W \ + "$( $1 --list-fixes 2>/dev/null | sed -e 1d )" -- "$cur" ) ) + return + ;; + -j|--processes) + COMPREPLY=( $( compgen -W "{1..$(_ncpus)}" -- "$cur" ) ) + return + ;; + -o|--output-dir) + _filedir -d + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) ) + [[ $COMPREPLY == *= ]] && compopt -o nospace + return + fi + + _filedir py +} && +complete -F _2to3 2to3 + +# ex: ts=4 sw=4 et filetype=sh diff --git a/completions/Makefile.am b/completions/Makefile.am index 899ef850..1b01eb2b 100644 --- a/completions/Makefile.am +++ b/completions/Makefile.am @@ -1,5 +1,6 @@ bashcompdir = $(pkgdatadir)/completions -bashcomp_DATA = 7z \ +bashcomp_DATA = 2to3 \ + 7z \ a2x \ abook \ aclocal \ diff --git a/test/completion/2to3.exp b/test/completion/2to3.exp new file mode 100644 index 00000000..9efdd77e --- /dev/null +++ b/test/completion/2to3.exp @@ -0,0 +1 @@ +assert_source_completions 2to3 diff --git a/test/lib/completions/2to3.exp b/test/lib/completions/2to3.exp new file mode 100644 index 00000000..101fbf87 --- /dev/null +++ b/test/lib/completions/2to3.exp @@ -0,0 +1,18 @@ +proc setup {} { + save_env +} + + +proc teardown {} { + assert_env_unmodified +} + + +setup + + +assert_complete_any "2to3 " +sync_after_int + + +teardown