Skip to content

Commit

Permalink
ri: Add option and arg completions
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed Apr 29, 2017
1 parent 1a61fc8 commit bf838e9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
30 changes: 28 additions & 2 deletions completions/ri
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,34 @@ _ri_get_methods()
# needs at least Ruby 1.8.0 in order to use -W0
_ri()
{
local cur prev words cword
_init_completion -n : || return
local cur prev words cword split
_init_completion -s -n : || return

case $prev in
-h|--help|-w|--width)
return
;;
-f|--format)
COMPREPLY=( $( compgen -W 'ansi bs html rdoc' -- "$cur" ) )
return
;;
-d|--doc-dir)
_filedir -d
return
;;
--dump)
_filedir ri
return
;;
esac

$split && return

if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '$( _parse_help "$1" )' -- "$cur" ) )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
fi

local class method prefix ri_path ri_version ri_major separator IFS
local -a classes
Expand Down
6 changes: 6 additions & 0 deletions test/lib/completions/ri.exp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ proc teardown {} {
setup


assert_complete_any "ri -"
sync_after_int

assert_complete "BashCompletion/ cache.ri" "ri --dump=$::srcdir/fixtures/ri/"
sync_after_int

assert_complete "BashCompletion" "ri BashCompletio"
sync_after_int

Expand Down

0 comments on commit bf838e9

Please sign in to comment.