From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7872 invoked by alias); 28 Mar 2018 01:01:42 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 42550 Received: (qmail 25693 invoked by uid 1010); 28 Mar 2018 01:01:42 -0000 X-Qmail-Scanner-Diagnostics: from park01.gkg.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(205.235.26.22):SA:0(0.2/5.0):. Processed in 28.421156 secs); 28 Mar 2018 01:01:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,DATE_IN_PAST_03_06, FILL_THIS_FORM,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,SPF_PASS,T_DKIM_INVALID,T_FILL_THIS_FORM_LONG, T_RP_MATCHES_RCVD autolearn=no autolearn_force=no version=3.4.1 X-Envelope-From: SRS0=TzE5=GS=yahoo.co.uk=okiddle@bounces.park01.gkg.net X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | X-Virus-Scanned: by amavisd-new at gkg.net Authentication-Results: amavisd4.gkg.net (amavisd-new); dkim=pass (2048-bit key) header.d=yahoo.co.uk X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.uk; s=s2048; t=1522198867; bh=3HWmUi8QsUCZveg1B1n5IS/3bWZOEFTgyYe7p3gOR2g=; h=From:To:Subject:Date:From:Subject; b=BJ335hBb8W75byeMVmD3HOHShVRE/OV7rUWoDFRL50F44ckkEQWJiBTF3lY9KpD6c6O537DBzuMNTbkUy9YbhTg0iKqrb6NWvqJLJzZxP2zfoKFeOMp4g2dLs89Zi/CGmiW2668zLP0p8/PG4fePDvWLtd4JT9ihHmNGSEu245dxmEJTLtRAZiRv+x1i/uyQHFxxZQIwZqTu5ibadmL4b1yVHS3vLm6+yk0nrjRYltAAchipdEXiqdqh0mwrhzHR43eqDet5uLaxXsGt68rkooTDm3Ez32P8FGXvQcsfLI44RQTONbpfQkSeodjlSMB2Wucefxu+5fLOsr9nTxnTAg== X-YMail-OSG: Cs935kkVM1mZCpVVPaPXzyxTFGaqOTCqgTTB6vtEM_c5Tkd_e17rGD2_vf32oxw .IlMm1dBnAmrifZ32XdgiEMt8aeax.OIRzwV_R_31XOPI73Hrb2jBoEICyomHiIU7PS94.DiDndD ROfwDR6bicHFOI.vCeYtGp5UiVYVhWh3Me9g7DmyioUaTupHz6xuf3Yh3_A596jSGNy0lwhBlgjl kwK_CiUweev6HOeNrztWS7DmKmgw9YXxKmxcy2cdwxucgIr981wFuB6vTov3YR2uAwQqKSZI8zfk iDO8eatp35iAGwOd3FNaX4jbM0N85Skj8ATEGB3ecIDFSYHKFcUYm_oZ7GHr0m56TjUYIMkBFexd uN09GuJqxMdqBUYXOF5aRMLpKTUey.52AdufwmTtPACwlAL7ihJydgQ9X5E5RyBUWzN1EERH73_h vVaRlH_6MaW3PHlNgvFU9vhaOh.tAYTTku03dyCYLvfmImTaVrxEUhHKEJ0OGKvCRBcMpF9wZMwt jd8MJI8617g-- From: Oliver Kiddle To: Zsh workers Subject: PATCH: new gem completion MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7365.1522186382.1@thecus> Content-Transfer-Encoding: quoted-printable Date: Tue, 27 Mar 2018 23:33:02 +0200 Message-ID: <7366.1522186382@thecus> This adds a completion function for ruby's gem. Oliver diff --git a/Completion/Unix/Command/_gem b/Completion/Unix/Command/_gem new file mode 100644 index 000000000..5b048f86d --- /dev/null +++ b/Completion/Unix/Command/_gem @@ -0,0 +1,303 @@ +#compdef gem -P gem[0-9.]# + +local curcontext=3D"$curcontext" state line expl ret=3D1 +local -A opt_args def +local -a args cmds helptopics proxy lropts filter +local cmd=3D"unknown" + +proxy=3D( + '(-p --http-proxy)'{-p,--http-proxy=3D}'[use HTTP proxy for remote oper= ations]:proxy url:_urls' +) +lropts=3D( $proxy + '${def[local]}(-l --local -r --remote -b --both)'{-l,--local}'[restrict= operations to the LOCAL domain]' + '${def[remote]}(-l --local -r --remote -b --both)'{-r,--remote}'[restri= ct operations to the REMOTE domain]' + '${def[both]}(-l --local -r --remote -b --both)'{-b,--both}'[allow LOCA= L and REMOTE operations]' + '(-B --bulk-threshold)'{-B,--bulk-threshold=3D}'[specify threshold for = switching to bulk synchronization]:threshold [1000]' + '--clear-sources[clear the gem sources]' + \*{-s,--source=3D}'[append specified URL to list of gem sources]:url:_u= rls' +) + +_arguments -C -s \ + '(* -)'{-h,--help}'[display usage information]' \ + '(* -)'{-v,--version}'[display version information]' \ + '*::command:->command' && ret=3D0 + +if [[ $state =3D command ]]; then + if (( CURRENT =3D=3D 1 )); then + cmd=3Dsubcommands + else + cmds=3D( + build cert check cleanup contents dependency environment fetch + generate_index help install list lock mirror open outdated owner + pristine push query rdoc search server signin signout sources + specification stale uninstall unpack update which yank + ) + cmds=3D( ${(M)cmds:#${words[1]}*} ) + if (( ${#cmds} =3D=3D 1 )); then + cmd=3D"$cmds[1]" + curcontext=3D"${curcontext%:*:*}:gem-${cmd}:" + fi + fi + case $cmd in + help) + helptopics=3D( + 'commands:list all gem commands' + 'examples:show some examples of usage' + 'gem_dependencies:gem dependencies file guide' + 'platforms:show information about platforms' + ) + _describe -t topics 'help topics' helptopics -- && ret=3D0 + ;& + subcommands) + cmds=3D( ${${${(M)${(f)"$(_call_program commands gem help commands)= "}:# [^ ]*}## #}/ ##/:} ) + _describe -t commands 'gem command' cmds -- && ret=3D0 + return ret + ;; + check|cleanup|contents|dependency|list|open|pristine|rdoc|uninstall|u= npack|update) + args+=3D( '(--all --skip)*:installed gem:->gems-local' ) + ;| + fetch|install|lock|owner|push|search|yank) + args+=3D( '*:gem:->gems-remote' ) + ;| + cleanup|uninstall) + args+=3D( '(-D --check-development)'{-D,--check-development}'[check= development dependencies while uninstalling]' ) + ;| + contents|pristine|rdoc) + args+=3D( '(*)--all[apply to all installed gems]' ) + ;| + list|query) def[local]=3D'!' ;| + search) def[remote]=3D'!' ;| + list|query|search) + args+=3D( ${(e)lropts} + '(-a --all)'{-a,--all}'[display all gem versions]' + '(-e --exact)'{-e,--exact}'[use exact string matching instead of = regex]' + '(-I --no-installed -i --installed)'{-i,--installed}'[check if ge= m is installed]' + '(-I --no-installed -i --installed)'{-I,--no-installed}'[check if= gem is not installed]' + '--no-versions[display only gem names]' + '(-d --details)'{-d,--details}'[display detailed gem information]= ' + '!(-d --details)--no-details' + ) + ;| + check|contents|dependency|fetch|install|list|open|pristine|query|rdoc= |search|specification|uninstall|unpack|yank) + args+=3D( '(-v --version)'{-v,--version=3D}'[specify version of gem= ]:version' ) + ;| + dependency|fetch|install|outdated|specification|uninstall|update|yank= ) + args+=3D( '--platform=3D[specify the platform of gem]:platform' ) + ;| + dependency|fetch|install|list|query|search|specification|update) + args+=3D( '--prerelease[include prerelease versions of a gem]' '!(-= -prerelease)--no-prerelease' ) + ;| + install|unpack|update) + args+=3D( '(-P --trust-policy)'{-P,--trust-policy=3D}'[specify gem = trust policy]:policy' ) + ;| + install|update) + def[both]=3D'!' + args+=3D( ${(e)lropts} + '(-N --no-document)--document=3D[generate documentation for insta= lled gems]::documentation type:_sequence compadd - rdoc ri' + '(-N --no-document --document)'{-N,--no-document}'[disable docume= ntation generation]' + '--build-root=3D[specify temporary installation root]:directory:_= directories' + '--vendor[install gem into the vendor directory]' + '(-f --force)'{-f,--force}'[force gem to install, bypassing depen= dency checks]' + "(-w --wrappers)--no-wrappers[don't install bin wrappers]" + '--format-executable[add matching version suffix on executables t= o ruby]' + "--user-install[install in user's home directory]" + '--development[install additional development dependencies]' + '--development-all[install development dependencies for all gems]= ' + "--conservative[don't attempt to upgrade gems already meeting ver= sion requirement]" + "--minimal-deps[don't upgrade any dependencies that already meet = version requirements]" + '--post-install-message[print post install message]' + '(-g --file)'{-g,--file=3D}'[read from a gem dependencies API fil= e and install the listed gems]:file:_files' + '--without=3D[omit the named groups when installing gem dependenc= ies]:group' + "--default[add the gem's full specification to specifications/def= ault and extract only its bin]" + '--explain[rather than install the gems, indicate which would be = installed]' + "--no-lock[don't create a lock file]" + '--suggestions[suggest alternates when gems are not found]' + ) + ;| + (un|)install|update) + args+=3D( + '--ignore-dependencies[ignore dependency requirements]' + '(-i --install-dir)'{-i,--install-dir=3D}'[specify gem repository= directory to get installed gems]:directory:_directories' + '(-n --bindir)'{-n,--bindir=3D}'[specify directory where binary f= iles are located]:directory:_directories' + ) + ;| + owner|push) + args+=3D( $proxy ) + ;| + owner|push|yank) + args+=3D( '(-k --key)'{-k,--key=3D}'[use specified API key from ~/.= gem/credentials]:key name' ) + ;| + owner|push|signin|yank) + args+=3D( '--host=3D[use another gemcutter-compatible host]:host:_u= rls' ) + ;| + install|pristine|update) + args+=3D( '(-E --env-shebang)'{-E,--env-shebang}'[rewrite executabl= es with a shebang of /usr/bin/env]' ) + ;| + + build) + args+=3D( + '--force[skip validation of the spec]' + '1:gemspec file:_files -g "*.gemspec(-.)"' + ) + ;; + cert) + args+=3D( + '(-a --add)'{-a,--add=3D}'[add a trusted certificate.]:certificat= e' \ + '(-l --list)'{-l,--list=3D}'[list trusted certificates where the = subject contains specified filter]:filter' + '(-r --remove)'{-r,--remove=3D}'[remove trusted certificates wher= e the subject contains specified filter]:filter' + '(-b --build)'{-b,--build=3D}'[build private key and self-signed = certificate for specified email address]:email address:_email_addresses -c= ' + '(-C --certificate)'{-C,--certificate=3D}'[specify signing certif= icate for --sign]:certificate' + '(-K --private-key)'{-K,--private-key=3D}'[specify key for --sign= or --build]:key' + '(-s --sign)'{-s,--sign=3D}'[sign specified certificate with the = key from -K and the certificate from -C]:certificate' + '(-d --days)'{-d,--days=3D}'[specify days before certificate expi= res]:days' + ) + ;; + check) + args+=3D( + "--no-alien[don't report \"unmanaged\" or rogue files in the gem = repository]" + '--doctor[clean up uninstalled gems and broken specifications]' + "--dry-run[don't remove files, only report what would be removed]= " + "--no-gems[don't check installed gems for problems]" + ) + ;; + cleanup) + args+=3D( '(-n -d --dryrun)'{-n,-d,--dryrun}"[don't uninstall gems]= " ) + ;; + contents) + args+=3D( + '(-s --spec-dir)'{-s,--spec-dir=3D}'[search for gems in specific = paths]:path:_sequence _directories' + '(-l --lib-only)'{-l,--lib-only}"[only return files in the Gem's = lib_dirs]" + '--no-prefix[include installed path prefix]' + '--show-install-dir[show only the gem install dir]' + ) + ;; + dependency) + def[local]=3D'!' + args+=3D( ${(e)lropts} + '(-R --reverse-dependencies)'{-R,--reverse-dependencies}'[include= reverse dependencies in the output]' + '--pipe[pipe format]' + ) + ;; + environment) + args+=3D( '1:information:(packageversion gemdir gempath version rem= otesources platform)' ) + ;; + fetch) + def=3D( both \! local \! remote \! ) + args+=3D( ${(e)lropts} ) + ;; + generate_index) + args+=3D( + '(-d --directory)'{-d,--directory=3D}'[specify repository base di= r containing gems]:directory:_directories' + '--update[update modern indexes with gems added since the last up= date]' + ) + ;; + lock) + args+=3D( '(-s --strict)'{-s,--strict}'[fail if unable to satisfy a= dependency]' ) + ;; + open) + args+=3D( '(-e --editor)'{-e,--editor=3D}'[open gem sources in spec= ified editor]:editor:_command_names -e' ) + ;; + outdated) + args+=3D( ${(e)lropts} ) + ;; + owner) + args+=3D( + '(-a --add)'{-a,--add=3D}'[add an owner]:email:_email_addresses -= c' + '(-r --remove)'{-r,--remove=3D}'[remove an owner]:email:_email_ad= dresses -c' + ) + ;; + pristine) + args+=3D( + '(*)*--skip=3D[with --all, skip specified gem]:installed gem:->ge= ms-local' + "--no-extensions[don't restore gems with extensions in addition t= o regular gems]" + '--only-executables[only restore executables]' + ) + ;; + push) + args+=3D( '*:gem:_files -g "*.gem(-.)"' ) + ;; + query) + args+=3D( + '(-n --name-matches)'{-n,--name-matches=3D}'[specify regex to mat= ch against gem names]:gem name (regex):->gems-local' + ) + ;; + rdoc) + args+=3D( + '--rdoc[generate RDoc HTML]' + '--no-ri[generate RI data]' + '--overwrite[overwrite installed documents]' + ) + ;; + server) + args+=3D( + '(-p --port)'{-p,--port=3D}'[specify port to listen on]:port [880= 8]:_ports' + '(-d --dir)'{-d,--dir=3D}'[specify directories from which to serv= e gems]:directory:_directories' + '--daemon[run as a daemon]' + '(-b --bind)'{-b,--bind=3D}'[specify addresses to bind]:host:_seq= uence _hosts' + '(-l --launch)'{-l,--launch=3D}'[launch a browser window]:command= :_command_names -e' + ) + ;; + sources) + args+=3D( $proxy + '(-a --add)'{-a,--add=3D}'[add source]:source URI:_urls' + '(-l --list)'{-l,--list}'[list sources]' + '(-r --remove)'{-r,--remove=3D}'[remove source]:source URI:_urls' + '(-c --clear-all)'{-c,--clear-all}'[remove all sources (clear the= cache)]' + '(-u --update)'{-u,--update}'[update source cache]' + ) + ;; + specification) + def[local]=3D'!' + args+=3D( ${(e)lropts} + '--all[output specifications for all versions of the gem]' + '!(--ruby --marshal)--yaml' '(--ruby --json)--marshal' '(--marsha= l --json 2)--ruby' + '1:gem:->gems-local' + '2:gemspec field:(name description version platform authors autor= equire bindir cert_chain date dependencies email executable executables ex= tensions extra_rdoc_files files homepage licenses metadata post_install_me= ssage rdoc_options require_paths required_ruby_version requirements rubyfo= rge_project rubygems_version signing_key specification_version summary tes= t_files)' + ) + ;; + uninstall) + args+=3D( + '(-a --all)'{-a,--all}'[uninstall all matching versions]' + '(-x --executables)'{-x,--executables}'[uninstall applicable exec= utables without confirmation]' + "--no-user-install[uninstall from user's home directory]" + "--format-executable[assume executable names match Ruby's prefix = and suffix]" + '--force[uninstall all versions of the named gems ignoring depend= encies]' + '--abort-on-dependent[prevent uninstalling gems that are depended= on by other gems]' + '--vendor[uninstall gem from the vendor directory]' + ) + ;; + unpack) + args+=3D( + '--spec[unpack the gem specification]' + '--target=3D[specify target directory for unpacking]:directory:_d= irectories' + ) + ;; + update) + args+=3D( '--system[update the RubyGems system software]::version' = ) + ;; + which) + args+=3D( + '(-a --all)'{-a,--all}'[show all matching files]' + '(-g --gems-first)'{-g,--gems-first}'[search gems before non-gems= ]' + '*:file:_files' + ) + ;; + esac + _arguments -C ${args:-'*: :_default'} \ + '(-)'{-h,--help}'[display usage information]' \ + '(-V --verbose --no-verbose)'{-V,--verbose,--no-verbose}'[set verbose= level of output]' \ + '(-q --quiet -V --verbose --no-verbose)'{-q,--quiet}'[silence command= s progress meter]' \ + '--silent[silence rubygems output]' \ + '--config-file=3D[use specified config file]:file:_files' \ + '--backtrace[show stack backtrace on errors]' \ + '--debug[turn on ruby debugging]' \ + '--norc[avoid loading any .gemrc file]' && ret=3D0 + + if [[ $state =3D=3D gems* ]]; then + filter=3D( ${${opt_args[(I)-([lbr]|-local|-remote|-both)]}:-${${(M)st= ate:#*-*}/gems-/--}} ) + _description gems expl gem + compadd "$expl[@]" ${${(f)"$(_call_program gems gem list $filter -q -= -no-versions)"}%% *} && ret=3D0 + fi +fi + +return ret