Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: update to ruby completions



This updates options in the completions for gem 3.4.10, ruby 3.2.2 and
ri 6.5.0.

Oliver

diff --git a/Completion/Unix/Command/_gem b/Completion/Unix/Command/_gem
index 7d81619bb..c5a64cdf1 100644
--- a/Completion/Unix/Command/_gem
+++ b/Completion/Unix/Command/_gem
@@ -20,6 +20,7 @@ lropts=( $proxy
 _arguments -C -s \
   '(* -)'{-h,--help}'[display usage information]' \
   '(* -)'{-v,--version}'[display version information]' \
+  '-C[change directory first]:directory:_directories' \
   '*::command:->command' && ret=0
 
 if [[ $state = command ]]; then
@@ -27,7 +28,7 @@ if [[ $state = command ]]; then
     cmd=subcommands
   else
     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
       pristine push query rdoc search server signin signout sources
       specification stale uninstall unpack update which yank
@@ -87,13 +88,13 @@ if [[ $state = command ]]; then
         '!(-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' )
     ;|
-    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' )
     ;|
-    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' )
     ;|
     install|unpack|update)
@@ -125,13 +126,13 @@ if [[ $state = command ]]; then
     ;|
     (un|)install|pristine|update)
       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'
       )
     ;|
     (un|)install|update)
       args+=(
         '--ignore-dependencies[ignore dependency requirements]'
-        '(-i --install-dir)'{-i,--install-dir=}'[specify gem repository directory to get installed gems]:directory:_directories'
       )
     ;|
     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'
         '(-C --certificate)'{-C,--certificate=}'[specify signing certificate for --sign]:certificate'
         '(-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'
         '(-d --days)'{-d,--days=}'[specify days before certificate expires]:days'
         '(-R --re-sign)'{-R,--re-sign}'[re-sign the certificate]'
@@ -181,7 +183,7 @@ if [[ $state = command ]]; then
     ;;
     cleanup)
       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]"
       )
     ;;
@@ -201,11 +203,20 @@ if [[ $state = command ]]; then
       )
     ;;
     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)
       def=( both \! local \! remote \! )
-      args+=( ${(e)lropts} )
+      args+=( ${(e)lropts}
+        "--no-suggestions[don't suggest alternates when gems are not found]"
+      )
     ;;
     generate_index)
       args+=(
@@ -232,13 +243,15 @@ if [[ $state = command ]]; then
       args+=(
         '(*)*--skip=[with --all, skip specified gem]:installed gem:->gems-local'
         "--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-plugins[only restore plugins]'
       )
     ;;
     push)
       args+=( '1:gem file:_files -g "*.gem(-.)"' )
     ;;
-    query)
+    query) # deprecated
       args+=(
         '(-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'
         '(-c --clear-all)'{-c,--clear-all}'[remove all sources (clear the cache)]'
         '(-u --update)'{-u,--update}'[update source cache]'
+        '(-f --force)'{-f,--force}"[don't show any confirmation prompts]"
       )
     ;;
     specification)
@@ -319,7 +333,7 @@ if [[ $state = command ]]; then
     '--norc[avoid loading any .gemrc file]' && ret=0
 
   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
     compadd "$expl[@]" ${${(f)"$(_call_program gems gem list $filter -q --no-versions)"}%% *} && ret=0
   fi
diff --git a/Completion/Unix/Command/_ri b/Completion/Unix/Command/_ri
index 4d5a72985..28de7a9a9 100644
--- a/Completion/Unix/Command/_ri
+++ b/Completion/Unix/Command/_ri
@@ -26,33 +26,22 @@ _arguments -C \
   '*:ri name:->ri-name' && return
 
 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
 
-  if "ruby${words[1]#ri}" -rrdoc/ri/ri_options -e 1 >/dev/null 2>&1; then
-    # 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
+  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)"} )
 
-  if compset -P '?*(::|\#|.)'; then
+  if compset -P '?*(::|:|\#|.)'; then
     class_dir=${IPREFIX//(::|\#|.)/\/}
   fi
   esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})}
 
   case "$IPREFIX" in
-    (*::) ri_wants=( 'classes:class names' 'class-methods:class methods' );;
-    (*\#) ri_wants=( 'instance-methods:instance methods' );;
-    (*.) ri_wants=( 'class-methods:class methods' 'instance-methods:instance methods' );;
-    (*) ri_wants=( 'classes:class names' )
+    (*::) ri_wants=( 'classes:class name' 'class-methods:class method' );;
+    (*:) ri_wants=( 'docs:documentation file' );;
+    (*\#) ri_wants=( 'instance-methods:instance method' );;
+    (*.) ri_wants=( 'class-methods:class method' 'instance-methods:instance method' );;
+    (*) ri_wants=( 'classes:class name' 'gems:gem' )
   esac
 
   for curtag in $ri_wants; do
@@ -63,27 +52,36 @@ if [[ "$state" = ri-name ]]; then
     while _tags; do
       while _next_label "$tag" expl "$descr"; do
         ri_wants=()
+        suf=()
         case "$tag" in
+          (gems)
+            ri_wants=( ruby ${${(f)"$(_call_program gems gem${words[1]#ri} list -q --no-versions)"}%% *} )
+            suf=( -S : )
+          ;;
           (classes)
           for dir in $ri_dirs[@]; do
             ri_wants+=( $dir/$class_dir*(-/:t) )
           done
+          suf=( -S '::' )
           ;;
           (class-methods)
           for dir in $ri_dirs[@]; do
-            fnames=( $dir/$class_dir*-c.$ri_ext(-.:t) )
-            ri_wants+=( ${${fnames%-c.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} )
+            fnames=( $dir/$class_dir*-c.ri(-.:t) )
+            ri_wants+=( ${${fnames%-c.ri//(#b)%(??)/$(print "\\x$match[1]")} )
           done
           ;;
           (instance-methods)
           for dir in $ri_dirs[@]; do
-            fnames=( $dir/$class_dir*-i.$ri_ext(-.:t) )
-            ri_wants+=( ${${fnames%-i.$ri_ext}//(#b)%(??)/$(print "\\x$match[1]")} )
+            fnames=( $dir/$class_dir*-i.ri(-.:t) )
+            ri_wants+=( ${${fnames%-i.ri}//(#b)%(??)/$(print "\\x$match[1]")} )
           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
         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
       (( ret )) || break
     done
diff --git a/Completion/Unix/Command/_ruby b/Completion/Unix/Command/_ruby
index 314307ebb..b6b42637d 100644
--- a/Completion/Unix/Command/_ruby
+++ b/Completion/Unix/Command/_ruby
@@ -44,6 +44,7 @@ opts=(
   \!--{en,dis}able-{gems,rubyopt,all}
   '--dump=[dump debug information]:information:_sequence compadd - insns insns_without_opt yydebug parsetree parsetree_with_comment'
   --{external,internal}'-encoding=:charset:->charsets'
+  '--backtrace-limit=[limit the maximum length of backtrace]:number'
   '!'{-y,--yydebug}
   '!--dump=:target:(version copyright usage yydebug syntax parsetree parsetree_with_comment insns)'
   '(--mjit --yjit)--jit[enable jit for the platform]'
@@ -65,11 +66,10 @@ opts=(
 
 irb=(
   '-f[suppress read of ~/.irbrc]'
-  '(--noinspect)-m[bc mode (load mathn, fraction, matrix)]'
   $opts[(r)*-d\[*]
   '(--noinspect)--inspect[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}
   '--tracer[display trace for each command execution]'
   '--back-trace-limit[set limit for backtraces]:limit [16]:'




Messages sorted by: Reverse Date, Date, Thread, Author