1
0
Fork 0
mirror of git://git.code.sf.net/p/zsh/code synced 2025-06-11 19:18:01 +02:00

52301: update options in completions for ruby 3.2, gem 3.4.10 and ri 6.5

This commit is contained in:
Oliver Kiddle 2023-11-14 20:39:23 +01:00
parent c3cb5a3e0c
commit 424746982b
4 changed files with 52 additions and 36 deletions
ChangeLog
Completion/Unix/Command

View file

@ -1,5 +1,9 @@
2023-11-14 Oliver Kiddle <opk@zsh.org> 2023-11-14 Oliver Kiddle <opk@zsh.org>
* 52301: Completion/Unix/Command/_gem, Completion/Unix/Command/_ri,
Completion/Unix/Command/_ruby: update options in completions for
ruby 3.2, gem 3.4.10 and ri 6.5
* 52300: Completion/Unix/Command/_ansible: ansible 2.15.2 updates * 52300: Completion/Unix/Command/_ansible: ansible 2.15.2 updates
2023-11-09 Oliver Kiddle <opk@zsh.org> 2023-11-09 Oliver Kiddle <opk@zsh.org>

View file

@ -20,6 +20,7 @@ lropts=( $proxy
_arguments -C -s \ _arguments -C -s \
'(* -)'{-h,--help}'[display usage information]' \ '(* -)'{-h,--help}'[display usage information]' \
'(* -)'{-v,--version}'[display version information]' \ '(* -)'{-v,--version}'[display version information]' \
'-C[change directory first]:directory:_directories' \
'*::command:->command' && ret=0 '*::command:->command' && ret=0
if [[ $state = command ]]; then if [[ $state = command ]]; then
@ -27,7 +28,7 @@ if [[ $state = command ]]; then
cmd=subcommands cmd=subcommands
else else
cmds=( cmds=(
build cert check cleanup contents dependency environment fetch build cert check cleanup contents dependency environment exec fetch
generate_index help install info list lock mirror open outdated owner generate_index help install info list lock mirror open outdated owner
pristine push query rdoc search server signin signout sources pristine push query rdoc search server signin signout sources
specification stale uninstall unpack update which yank specification stale uninstall unpack update which yank
@ -87,13 +88,13 @@ if [[ $state = command ]]; then
'!(-d --details)--no-details' '!(-d --details)--no-details'
) )
;| ;|
check|contents|dependency|fetch|install|list|open|pristine|query|rdoc|search|specification|uninstall|unpack|yank) check|contents|dependency|exec|fetch|install|list|open|pristine|query|rdoc|search|specification|uninstall|unpack|yank)
args+=( '(-v --version)'{-v,--version=}'[specify version of gem]:version' ) args+=( '(-v --version)'{-v,--version=}'[specify version of gem]:version' )
;| ;|
dependency|fetch|install|outdated|specification|uninstall|update|yank) build|dependency|fetch|install|outdated|specification|uninstall|update|yank)
args+=( '--platform=[specify the platform of gem]:platform' ) args+=( '--platform=[specify the platform of gem]:platform' )
;| ;|
dependency|fetch|install|list|query|search|specification|update) dependency|exec|fetch|install|list|query|search|specification|update)
args+=( '--prerelease[include prerelease versions of a gem]' '!(--prerelease)--no-prerelease' ) args+=( '--prerelease[include prerelease versions of a gem]' '!(--prerelease)--no-prerelease' )
;| ;|
install|unpack|update) install|unpack|update)
@ -125,13 +126,13 @@ if [[ $state = command ]]; then
;| ;|
(un|)install|pristine|update) (un|)install|pristine|update)
args+=( args+=(
'(-i --install-dir)'{-i,--install-dir=}'[specify gem repository directory to get installed gems]:directory:_directories'
'(-n --bindir)'{-n,--bindir=}'[specify directory where binary files are located]:directory:_directories' '(-n --bindir)'{-n,--bindir=}'[specify directory where binary files are located]:directory:_directories'
) )
;| ;|
(un|)install|update) (un|)install|update)
args+=( args+=(
'--ignore-dependencies[ignore dependency requirements]' '--ignore-dependencies[ignore dependency requirements]'
'(-i --install-dir)'{-i,--install-dir=}'[specify gem repository directory to get installed gems]:directory:_directories'
) )
;| ;|
owner|push) owner|push)
@ -166,6 +167,7 @@ if [[ $state = command ]]; then
'(-b --build)'{-b,--build=}'[build private key and self-signed certificate for specified email address]:email address:_email_addresses -c' '(-b --build)'{-b,--build=}'[build private key and self-signed certificate for specified email address]:email address:_email_addresses -c'
'(-C --certificate)'{-C,--certificate=}'[specify signing certificate for --sign]:certificate' '(-C --certificate)'{-C,--certificate=}'[specify signing certificate for --sign]:certificate'
'(-K --private-key)'{-K,--private-key=}'[specify key for --sign or --build]:key' '(-K --private-key)'{-K,--private-key=}'[specify key for --sign or --build]:key'
'(-A --key-algorithm)'{-A,--key-algorithm=}'[select which key algorithm to use for --build]:algorithm'
'(-s --sign)'{-s,--sign=}'[sign specified certificate with the key from -K and the certificate from -C]:certificate' '(-s --sign)'{-s,--sign=}'[sign specified certificate with the key from -K and the certificate from -C]:certificate'
'(-d --days)'{-d,--days=}'[specify days before certificate expires]:days' '(-d --days)'{-d,--days=}'[specify days before certificate expires]:days'
'(-R --re-sign)'{-R,--re-sign}'[re-sign the certificate]' '(-R --re-sign)'{-R,--re-sign}'[re-sign the certificate]'
@ -181,7 +183,7 @@ if [[ $state = command ]]; then
;; ;;
cleanup) cleanup)
args+=( args+=(
'(-n -d --dryrun)'{-n,-d,--dryrun}"[don't uninstall gems]" '(-n -d --dry-run)'{-n,-d,--dry-run}"[don't uninstall gems]"
"--user-install[cleanup in user's home directory instead of GEM_HOME]" "--user-install[cleanup in user's home directory instead of GEM_HOME]"
) )
;; ;;
@ -201,11 +203,20 @@ if [[ $state = command ]]; then
) )
;; ;;
environment) environment)
args+=( '1:information:(gemdir gempath version remotesources platform)' ) args+=( '1:information:(gemdir gempath home path user_gemhome version remotesources platform)' )
;;
exec)
args+=(
'--conservative[prefer most recent installed version to the overall latest]'
'1:gem:->gems-remote'
'*: :_default'
)
;; ;;
fetch) fetch)
def=( both \! local \! remote \! ) def=( both \! local \! remote \! )
args+=( ${(e)lropts} ) args+=( ${(e)lropts}
"--no-suggestions[don't suggest alternates when gems are not found]"
)
;; ;;
generate_index) generate_index)
args+=( args+=(
@ -232,13 +243,15 @@ if [[ $state = command ]]; then
args+=( args+=(
'(*)*--skip=[with --all, skip specified gem]:installed gem:->gems-local' '(*)*--skip=[with --all, skip specified gem]:installed gem:->gems-local'
"--no-extensions[don't restore gems with extensions in addition to regular gems]" "--no-extensions[don't restore gems with extensions in addition to regular gems]"
'--only-missing-extensions[only restore gems with missing extensions]'
'--only-executables[only restore executables]' '--only-executables[only restore executables]'
'--only-plugins[only restore plugins]'
) )
;; ;;
push) push)
args+=( '1:gem file:_files -g "*.gem(-.)"' ) args+=( '1:gem file:_files -g "*.gem(-.)"' )
;; ;;
query) query) # deprecated
args+=( args+=(
'(-n --name-matches)'{-n,--name-matches=}'[specify regex to match against gem names]:gem name (regex):->gems-local' '(-n --name-matches)'{-n,--name-matches=}'[specify regex to match against gem names]:gem name (regex):->gems-local'
) )
@ -266,6 +279,7 @@ if [[ $state = command ]]; then
'(-r --remove)'{-r,--remove=}'[remove source]:source URI:_urls' '(-r --remove)'{-r,--remove=}'[remove source]:source URI:_urls'
'(-c --clear-all)'{-c,--clear-all}'[remove all sources (clear the cache)]' '(-c --clear-all)'{-c,--clear-all}'[remove all sources (clear the cache)]'
'(-u --update)'{-u,--update}'[update source cache]' '(-u --update)'{-u,--update}'[update source cache]'
'(-f --force)'{-f,--force}"[don't show any confirmation prompts]"
) )
;; ;;
specification) specification)
@ -319,7 +333,7 @@ if [[ $state = command ]]; then
'--norc[avoid loading any .gemrc file]' && ret=0 '--norc[avoid loading any .gemrc file]' && ret=0
if [[ $state == gems* ]]; then if [[ $state == gems* ]]; then
filter=( ${${opt_args[(I)-([lbr]|-local|-remote|-both)]}:-${${(M)state:#*-*}/gems-/--}} ) filter=( ${${opt_args[(I)-([lbr]|-conservative|-local|-remote|-both)]/conservative/local}:-${${(M)state:#*-*}/gems-/--}} )
_description gems expl gem _description gems expl gem
compadd "$expl[@]" ${${(f)"$(_call_program gems gem list $filter -q --no-versions)"}%% *} && ret=0 compadd "$expl[@]" ${${(f)"$(_call_program gems gem list $filter -q --no-versions)"}%% *} && ret=0
fi fi

View file

@ -26,33 +26,22 @@ _arguments -C \
'*:ri name:->ri-name' && return '*:ri name:->ri-name' && return
if [[ "$state" = ri-name ]]; then if [[ "$state" = ri-name ]]; then
local -a ri_dirs ri_ext ri_names ri_wants ri_names local -a ri_dirs ri_names ri_wants ri_names
local class_dir esc_name dir curtag tag descr expl local class_dir esc_name dir curtag tag descr expl
if "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e 1 >/dev/null 2>&1; then ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f bs -T)"} )
# Old-style Ruby 1.8.x RI
ri_dirs=( ${(f)"$(_call_program ri-names "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e '"o = RI::Options.instance; o.parse(ARGV); o.path.each { |p| puts p }"' -- ${(kv)opt_args[(I)-d|--doc-dir|--(system|site|gems|home)]})"} )
ri_ext=yaml
elif "ruby${words[1]#ri}" -rrdoc/ri -rrdoc/ri/store -e 1 >/dev/null 2>&1; then
# Newer-style Ruby 1.9.2 RI
ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f bs -T)"} )
ri_ext=ri
else
# New-style Ruby 1.9+ RI
ri_dirs=( ${(f)"$(_call_program ri-names "$words[1]" ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} --list-doc-dirs -f plain -T)"} )
ri_ext=yaml
fi
if compset -P '?*(::|\#|.)'; then if compset -P '?*(::|:|\#|.)'; then
class_dir=${IPREFIX//(::|\#|.)/\/} class_dir=${IPREFIX//(::|\#|.)/\/}
fi fi
esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})} esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})}
case "$IPREFIX" in case "$IPREFIX" in
(*::) ri_wants=( 'classes:class names' 'class-methods:class methods' );; (*::) ri_wants=( 'classes:class name' 'class-methods:class method' );;
(*\#) ri_wants=( 'instance-methods:instance methods' );; (*:) ri_wants=( 'docs:documentation file' );;
(*.) ri_wants=( 'class-methods:class methods' 'instance-methods:instance methods' );; (*\#) ri_wants=( 'instance-methods:instance method' );;
(*) ri_wants=( 'classes:class names' ) (*.) ri_wants=( 'class-methods:class method' 'instance-methods:instance method' );;
(*) ri_wants=( 'classes:class name' 'gems:gem' )
esac esac
for curtag in $ri_wants; do for curtag in $ri_wants; do
@ -63,27 +52,36 @@ if [[ "$state" = ri-name ]]; then
while _tags; do while _tags; do
while _next_label "$tag" expl "$descr"; do while _next_label "$tag" expl "$descr"; do
ri_wants=() ri_wants=()
suf=()
case "$tag" in case "$tag" in
(gems)
ri_wants=( ruby ${${(f)"$(_call_program gems gem${words[1]#ri} list -q --no-versions)"}%% *} )
suf=( -S : )
;;
(classes) (classes)
for dir in $ri_dirs[@]; do for dir in $ri_dirs[@]; do
ri_wants+=( $dir/$class_dir*(-/:t) ) ri_wants+=( $dir/$class_dir*(-/:t) )
done done
suf=( -S '::' )
;; ;;
(class-methods) (class-methods)
for dir in $ri_dirs[@]; do for dir in $ri_dirs[@]; do
fnames=( $dir/$class_dir*-c.$ri_ext(-.:t) ) fnames=( $dir/$class_dir*-c.ri(-.:t) )
ri_wants+=( ${${fnames%-c.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} ) ri_wants+=( ${${fnames%-c.ri//(#b)%(??)/$(print "\\x$match[1]")} )
done done
;; ;;
(instance-methods) (instance-methods)
for dir in $ri_dirs[@]; do for dir in $ri_dirs[@]; do
fnames=( $dir/$class_dir*-i.$ri_ext(-.:t) ) fnames=( $dir/$class_dir*-i.ri(-.:t) )
ri_wants+=( ${${fnames%-i.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} ) ri_wants+=( ${${fnames%-i.ri}//(#b)%(??)/$(print "\\x$match[1]")} )
done done
;; ;;
(docs)
ri_wants=( ${${(f)"$(_call_program docs $words[1] ${(kv)opt_args[(I)-d|--doc-dir|--((no-|)(system|site|gems|home)|standard-docs)]} $IPREFIX)"}:#=*} )
;;
esac esac
ri_names=( ${(Q)ri_wants} ) ri_names=( ${(Q)ri_wants} )
compadd -S '' -d ri_names -a "$expl[@]" ri_wants && ret=0 compadd $suf -d ri_names -a "$expl[@]" ri_wants && ret=0
done done
(( ret )) || break (( ret )) || break
done done

View file

@ -44,6 +44,7 @@ opts=(
\!--{en,dis}able-{gems,rubyopt,all} \!--{en,dis}able-{gems,rubyopt,all}
'--dump=[dump debug information]:information:_sequence compadd - insns insns_without_opt yydebug parsetree parsetree_with_comment' '--dump=[dump debug information]:information:_sequence compadd - insns insns_without_opt yydebug parsetree parsetree_with_comment'
--{external,internal}'-encoding=:charset:->charsets' --{external,internal}'-encoding=:charset:->charsets'
'--backtrace-limit=[limit the maximum length of backtrace]:number'
'!'{-y,--yydebug} '!'{-y,--yydebug}
'!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)' '!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)'
'(--mjit --yjit)--jit[enable jit for the platform]' '(--mjit --yjit)--jit[enable jit for the platform]'
@ -65,11 +66,10 @@ opts=(
irb=( irb=(
'-f[suppress read of ~/.irbrc]' '-f[suppress read of ~/.irbrc]'
'(--noinspect)-m[bc mode (load mathn, fraction, matrix)]'
$opts[(r)*-d\[*] $opts[(r)*-d\[*]
'(--noinspect)--inspect[use inspect for output]' '(--noinspect)--inspect[use inspect for output]'
"(--inspect)--noinspect[don't use inspect for output]" "(--inspect)--noinspect[don't use inspect for output]"
'(--prompt --prompt-mode --inf-ruby-mode --simple-prompt --noprompt)'{--prompt,--prompt-mode}'[switch prompt mode]:prompt mode:(default simple xmp inf-ruby)' '(--prompt --prompt-mode --inf-ruby-mode --simple-prompt --noprompt)'{--prompt=,--prompt-mode=}'[switch prompt mode]:prompt mode:(default classic simple inf-ruby xmp null)'
'(--prompt --prompt-mode --inf-ruby-mode --simple-prompt --noprompt)'{--inf-ruby-mode,--simple-prompt,--noprompt} '(--prompt --prompt-mode --inf-ruby-mode --simple-prompt --noprompt)'{--inf-ruby-mode,--simple-prompt,--noprompt}
'--tracer[display trace for each command execution]' '--tracer[display trace for each command execution]'
'--back-trace-limit[set limit for backtraces]:limit [16]:' '--back-trace-limit[set limit for backtraces]:limit [16]:'