Skip to content

Commit

Permalink
perltidy: New completion
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Dec 16, 2017
1 parent fbd52a5 commit 9cddfdf
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ bashcomp_DATA = 2to3 \
patch \
pdftotext \
perl \
perltidy \
pgrep \
pidof \
pine \
Expand Down
53 changes: 53 additions & 0 deletions completions/perltidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# perltidy(1) completion -*- shell-script -*-

_perltidy()
{
local cur prev words cword
_init_completion -n = || return

case $prev in
-h|--help)
return
;;
-o)
_filedir
return
;;
esac

case $cur in
-pro=*)
cur="${cur#*=}"
_filedir
return
;;
-ole=*)
COMPREPLY=( $( compgen -W 'dos win mac unix' -- "${cur#*=}" ) )
return
;;
-bt=*|-pt=*|-sbt=*|-bvt=*|-pvt=*|-sbvt=*|-bvtc=*|-pvtc=*|-sbvtc=*|\
-cti=*|-kbl=*|-vt=*)
COMPREPLY=( $( compgen -W '0 1 2' -- "${cur#*=}" ) )
return
;;
-vtc=*)
COMPREPLY=( $( compgen -W '0 1' -- "${cur#*=}" ) )
return
;;
-cab=*)
COMPREPLY=( $( compgen -W '0 1 2 3' -- "${cur#*=}" ) )
return
;;
-*=)
return
;;
esac

if [[ $cur == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
else
_filedir 'p[lm]'
fi
} &&
complete -F _perltidy perltidy
1 change: 1 addition & 0 deletions test/completion/perltidy.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
assert_source_completions perltidy
27 changes: 27 additions & 0 deletions test/lib/completions/perltidy.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
proc setup {} {
save_env
}


proc teardown {} {
assert_env_unmodified
}


setup


assert_complete_any "perltidy "
sync_after_int

assert_complete_any "perltidy -h"
sync_after_int

assert_complete_any "perltidy -ole="
sync_after_int

assert_no_complete "perltidy -doesntexist="
sync_after_int


teardown

0 comments on commit 9cddfdf

Please sign in to comment.