mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2024-11-19 21:41:07 +01:00
cargo: update completion to latest version (cdac4a8)
https://github.com/rust-lang/cargo/blob/cdac4a8/src/etc/_cargo
This commit is contained in:
parent
aebf333b0c
commit
05dfd0ae85
1 changed files with 326 additions and 463 deletions
|
@ -2,489 +2,367 @@
|
||||||
|
|
||||||
autoload -U regexp-replace
|
autoload -U regexp-replace
|
||||||
|
|
||||||
zstyle -T ':completion:*:*:cargo:*' tag-order && \
|
|
||||||
zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
|
|
||||||
|
|
||||||
_cargo() {
|
_cargo() {
|
||||||
local context state state_descr line
|
local curcontext="$curcontext" ret=1
|
||||||
typeset -A opt_args
|
local -a command_scope_spec common parallel features msgfmt triple target registry
|
||||||
|
local -a state line state_descr # These are set by _arguments
|
||||||
|
typeset -A opt_args
|
||||||
|
|
||||||
# leading items in parentheses are an exclusion list for the arguments following that arg
|
common=(
|
||||||
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
|
'(-q --quiet)*'{-v,--verbose}'[use verbose output]'
|
||||||
# - => exclude all other options
|
'(-q --quiet -v --verbose)'{-q,--quiet}'[no output printed to stdout]'
|
||||||
# 1 => exclude positional arg 1
|
'-Z+[pass unstable (nightly-only) flags to cargo]: :_cargo_unstable_flags'
|
||||||
# * => exclude all other args
|
'--frozen[require that Cargo.lock and cache are up-to-date]'
|
||||||
# +blah => exclude +blah
|
'--locked[require that Cargo.lock is up-to-date]'
|
||||||
_arguments \
|
'--color=[specify colorization option]:coloring:(auto always never)'
|
||||||
'(- 1 *)'{-h,--help}'[show help message]' \
|
'(- 1 *)'{-h,--help}'[show help message]'
|
||||||
'(- 1 *)--list[list installed commands]' \
|
)
|
||||||
'(- 1 *)'{-V,--version}'[show version information]' \
|
|
||||||
{-v,--verbose}'[use verbose output]' \
|
|
||||||
--color'[colorization option]' \
|
|
||||||
'(+beta +nightly)+stable[use the stable toolchain]' \
|
|
||||||
'(+stable +nightly)+beta[use the beta toolchain]' \
|
|
||||||
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
|
||||||
'1: :->command' \
|
|
||||||
'*:: :->args'
|
|
||||||
|
|
||||||
case $state in
|
# leading items in parentheses are an exclusion list for the arguments following that arg
|
||||||
command)
|
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
|
||||||
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
|
# - => exclude all other options
|
||||||
;;
|
# 1 => exclude positional arg 1
|
||||||
|
# * => exclude all other args
|
||||||
|
# +blah => exclude +blah
|
||||||
|
_arguments -s -S -C $common \
|
||||||
|
'(- 1 *)--list[list installed commands]' \
|
||||||
|
'(- 1 *)--explain=[provide a detailed explanation of an error message]:error code' \
|
||||||
|
'(- 1 *)'{-V,--version}'[show version information]' \
|
||||||
|
'(+beta +nightly)+stable[use the stable toolchain]' \
|
||||||
|
'(+stable +nightly)+beta[use the beta toolchain]' \
|
||||||
|
'(+stable +beta)+nightly[use the nightly toolchain]' \
|
||||||
|
'1: :_cargo_cmds' \
|
||||||
|
'*:: :->args'
|
||||||
|
|
||||||
args)
|
# These flags are mutually exclusive specifiers for the scope of a command; as
|
||||||
case $words[1] in
|
# they are used in multiple places without change, they are expanded into the
|
||||||
bench)
|
# appropriate command's `_arguments` where appropriate.
|
||||||
_arguments \
|
command_scope_spec=(
|
||||||
'--features=[space separated feature list]' \
|
'(--bin --example --test --lib)--bench=[specify benchmark name]: :_cargo_benchmark_names'
|
||||||
'--all-features[enable all available features]' \
|
'(--bench --bin --test --lib)--example=[specify example name]:example name'
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'(--bench --example --test --lib)--bin=[specify binary name]:binary name'
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
'(--bench --bin --example --test)--lib=[specify library name]:library name'
|
||||||
"${command_scope_spec[@]}" \
|
'(--bench --bin --example --lib)--test=[specify test name]:test name'
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
)
|
||||||
'--no-default-features[do not build the default features]' \
|
|
||||||
'--no-run[compile but do not run]' \
|
|
||||||
'(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
|
|
||||||
'--target=[target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
build)
|
parallel=(
|
||||||
_arguments \
|
'(-j --jobs)'{-j+,--jobs=}'[specify number of parallel jobs]:jobs [# of CPUs]'
|
||||||
'--features=[space separated feature list]' \
|
)
|
||||||
'--all-features[enable all available features]' \
|
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
|
||||||
"${command_scope_spec[@]}" \
|
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
'--no-default-features[do not build the default features]' \
|
|
||||||
'(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
|
|
||||||
'--release=[build in release mode]' \
|
|
||||||
'--target=[target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
check)
|
features=(
|
||||||
_arguments \
|
'(--all-features)--features=[specify features to activate]:feature'
|
||||||
'--features=[space separated feature list]' \
|
'(--features)--all-features[activate all available features]'
|
||||||
'--all-features[enable all available features]' \
|
"--no-default-features[don't build the default features]"
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
)
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
|
||||||
"${command_scope_spec[@]}" \
|
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
'--no-default-features[do not check the default features]' \
|
|
||||||
'(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \
|
|
||||||
'--release=[check in release mode]' \
|
|
||||||
'--target=[target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
clean)
|
msgfmt='--message-format=[specify error format]:error format [human]:(human json short)'
|
||||||
_arguments \
|
triple='--target=[specify target triple]:target triple'
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
target='--target-dir=[specify directory for all generated artifacts]:directory:_directories'
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
manifest='--manifest-path=[specify path to manifest]:path:_directories'
|
||||||
'(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
|
registry='--registry=[specify registry to use]:registry'
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--release[whether or not to clean release artifacts]' \
|
|
||||||
'--target=[target triple(default:all)]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
doc)
|
case $state in
|
||||||
_arguments \
|
args)
|
||||||
'--features=[space separated feature list]' \
|
curcontext="${curcontext%:*}-${words[1]}:"
|
||||||
'--all-features[enable all available features]' \
|
case ${words[1]} in
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
bench)
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
_arguments -s -A "^--" $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
"${command_scope_spec[@]}" \
|
||||||
'--no-deps[do not build docs for dependencies]' \
|
'--all-targets[benchmark all targets]' \
|
||||||
'--no-default-features[do not build the default features]' \
|
"--no-run[compile but don't run]" \
|
||||||
'--open[open docs in browser after the build]' \
|
'(-p --package)'{-p+,--package=}'[specify package to run benchmarks for]:package:_cargo_package_names' \
|
||||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
'--exclude=[exclude packages from the benchmark]:spec' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'--no-fail-fast[run all benchmarks regardless of failure]' \
|
||||||
'--release[build artifacts in release mode, with optimizations]' \
|
'1: :_guard "^-*" "bench name"' \
|
||||||
'--target=[build for the target triple]' \
|
'*:args:_default'
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
;;
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
fetch)
|
build)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
"${command_scope_spec[@]}" \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--release[build in release mode]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'--build-plan[output the build plan in JSON]' \
|
||||||
;;
|
;;
|
||||||
|
|
||||||
generate-lockfile)
|
check)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--all-targets[equivalent to specifying --lib --bins --tests --benches --examples]' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
"${command_scope_spec[@]}" \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'(-p --package)'{-p+,--package=}'[specify package to check]:package:_cargo_package_names' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--release[check in release mode]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
git-checkout)
|
clean)
|
||||||
_arguments \
|
_arguments -s -S $common $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'(-p --package)'{-p+,--package=}'[specify package to clean]:package:_cargo_package_names' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'--release[clean release artifacts]' \
|
||||||
'--reference=[REF]' \
|
'--doc[clean just the documentation directory]'
|
||||||
'--url=[URL]' \
|
;;
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
help)
|
doc)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--no-deps[do not build docs for dependencies]' \
|
||||||
'*: :_cargo_cmds' \
|
'--document-private-items[include non-public items in the documentation]' \
|
||||||
;;
|
'--open[open docs in browser after the build]' \
|
||||||
|
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||||
|
'--release[build artifacts in release mode, with optimizations]' \
|
||||||
|
;;
|
||||||
|
|
||||||
init)
|
fetch)
|
||||||
_arguments \
|
_arguments -s -S $common $triple $manifest
|
||||||
'--bin[use binary template]' \
|
;;
|
||||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
|
||||||
'--name=[set the resulting package name]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
install)
|
fix)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'--bin=[only install the specified binary]' \
|
"${command_scope_spec[@]}" \
|
||||||
'--branch=[branch to use when installing from git]' \
|
'--broken-code[fix code even if it already has compiler errors]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'--edition[fix in preparation for the next edition]' \
|
||||||
'--debug[build in debug mode instead of release mode]' \
|
'--edition-idioms[fix warnings to migrate to the idioms of an edition]' \
|
||||||
'--example[install the specified example instead of binaries]' \
|
'--allow-no-vcs[fix code even if a VCS was not detected]' \
|
||||||
'--features=[space separated feature list]' \
|
'--allow-dirty[fix code even if the working directory is dirty]' \
|
||||||
'--all-features[enable all available features]' \
|
'--allow-staged[fix code even if the working directory has staged changes]'
|
||||||
'--git=[URL from which to install the crate]' \
|
;;
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
|
||||||
'--no-default-features[do not build the default features]' \
|
|
||||||
'--path=[local filesystem path to crate to install]: :_files -/' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--rev=[specific commit to use when installing from git]' \
|
|
||||||
'--root=[directory to install packages into]: :_files -/' \
|
|
||||||
'--tag=[tag to use when installing from git]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--vers=[version to install from crates.io]' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
locate-project)
|
generate-lockfile)
|
||||||
_arguments \
|
_arguments -s -S $common $manifest
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
;;
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
login)
|
git-checkout)
|
||||||
_arguments \
|
_arguments -s -S $common \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--reference=:reference' \
|
||||||
'--host=[Host to set the token for]' \
|
'--url=:url:_urls'
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
;;
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
metadata)
|
help)
|
||||||
_arguments \
|
_cargo_cmds
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
;;
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
|
||||||
'--no-default-features[do not include the default feature]' \
|
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
'--features=[space separated feature list]' \
|
|
||||||
'--all-features[enable all available features]' \
|
|
||||||
'--format-version=[format version(default: 1)]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
new)
|
init)
|
||||||
_arguments \
|
_arguments -s -S $common $registry \
|
||||||
'--bin[use binary template]' \
|
'--lib[use library template]' \
|
||||||
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
'--edition=[specify edition to set for the crate generated]:edition:(2015 2018)' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--vcs=[initialize a new repo with a given VCS]:vcs:(git hg pijul fossil none)' \
|
||||||
'--name=[set the resulting package name]' \
|
'--name=[set the resulting package name]:name' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'1:path:_directories'
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
;;
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
owner)
|
install)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $triple $registry \
|
||||||
'(-a, --add)'{-a,--add}'[add owner LOGIN]' \
|
'(-f --force)'{-f,--force}'[force overwriting of existing crates or binaries]' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--bin=[only install the specified binary]:binary' \
|
||||||
'--index[registry index]' \
|
'--branch=[branch to use when installing from git]:branch' \
|
||||||
'(-l, --list)'{-l,--list}'[list owners of a crate]' \
|
'--debug[build in debug mode instead of release mode]' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'--example=[install the specified example instead of binaries]:example' \
|
||||||
'(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
|
'--git=[specify URL from which to install the crate]:url:_urls' \
|
||||||
'--token[API token to use when authenticating]' \
|
'--path=[local filesystem path to crate to install]: :_directories' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--rev=[specific commit to use when installing from git]:commit' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'--root=[directory to install packages into]: :_directories' \
|
||||||
;;
|
'--tag=[tag to use when installing from git]:tag' \
|
||||||
|
'--vers=[version to install from crates.io]:version' \
|
||||||
|
'--list[list all installed packages and their versions]' \
|
||||||
|
'*: :_guard "^-*" "crate"'
|
||||||
|
;;
|
||||||
|
|
||||||
package)
|
locate-project)
|
||||||
_arguments \
|
_arguments -s -S $common $manifest
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
;;
|
||||||
'(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
|
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
|
||||||
'--no-verify[do not build to verify contents]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
pkgid)
|
login)
|
||||||
_arguments \
|
_arguments -s -S $common $registry \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'*: :_guard "^-*" "token"'
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
;;
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
publish)
|
metadata)
|
||||||
_arguments \
|
_arguments -s -S $common $features $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
"--no-deps[output information only about the root package and don't fetch dependencies]" \
|
||||||
'--host=[Host to set the token for]' \
|
'--format-version=[specify format version]:version [1]:(1)'
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
;;
|
||||||
'--no-verify[Do not verify tarball until before publish]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--token[token to use when uploading]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
read-manifest)
|
new)
|
||||||
_arguments \
|
_arguments -s -S $common $registry \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--lib[use library template]' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
'--vcs:initialize a new repo with a given VCS:(git hg none)' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--name=[set the resulting package name]'
|
||||||
'--color=:colorization option:(auto always never)' \
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
run)
|
owner)
|
||||||
_arguments \
|
_arguments -s -S $common $registry \
|
||||||
'--example=[name of the bin target]' \
|
'(-a --add)'{-a,--add}'[specify name of a user or team to invite as an owner]:name' \
|
||||||
'--features=[space separated feature list]' \
|
'--index=[specify registry index]:index' \
|
||||||
'--all-features[enable all available features]' \
|
'(-l --list)'{-l,--list}'[list owners of a crate]' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'(-r --remove)'{-r,--remove}'[specify name of a user or team to remove as an owner]:name' \
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
'--token=[specify API token to use when authenticating]:token' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
'*: :_guard "^-*" "crate"'
|
||||||
'--bin=[name of the bin target]' \
|
;;
|
||||||
'--no-default-features[do not build the default features]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--release=[build in release mode]' \
|
|
||||||
'--target=[target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
'*: :_normal' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
rustc)
|
package)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $triple $target $manifest \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'(-l --list)'{-l,--list}'[print files included in a package without making one]' \
|
||||||
'--features=[features to compile for the package]' \
|
'--no-metadata[ignore warnings about a lack of human-usable metadata]' \
|
||||||
'--all-features[enable all available features]' \
|
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
"--no-verify[don't build to verify contents]"
|
||||||
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
|
;;
|
||||||
'--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \
|
|
||||||
'--no-default-features[do not compile default features for the package]' \
|
|
||||||
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
|
|
||||||
'--profile=[profile to build the selected target for]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--release[build artifacts in release mode, with optimizations]' \
|
|
||||||
'--target=[target triple which compiles will be for]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
"${command_scope_spec[@]}" \
|
|
||||||
;;
|
|
||||||
|
|
||||||
rustdoc)
|
pkgid)
|
||||||
_arguments \
|
_arguments -s -S $common $manifest \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'(-p --package)'{-p+,--package=}'[specify package to get ID specifier for]:package:_cargo_package_names' \
|
||||||
'--features=[space-separated list of features to also build]' \
|
'*: :_guard "^-*" "spec"'
|
||||||
'--all-features[enable all available features]' \
|
;;
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
|
||||||
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
|
|
||||||
'--manifest-path=[path to the manifest to document]: :_files -/' \
|
|
||||||
'--no-default-features[do not build the `default` feature]' \
|
|
||||||
'--open[open the docs in a browser after the operation]' \
|
|
||||||
'(-p, --package)'{-p,--package}'=[package to document]' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--release[build artifacts in release mode, with optimizations]' \
|
|
||||||
'--target=[build for the target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
"${command_scope_spec[@]}" \
|
|
||||||
;;
|
|
||||||
|
|
||||||
search)
|
publish)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $triple $target $manifest $registry \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'--index=[specify registry index]:index' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--allow-dirty[allow dirty working directories to be packaged]' \
|
||||||
'--host=[host of a registry to search in]' \
|
"--no-verify[don't verify the contents by building them]" \
|
||||||
'--limit=[limit the number of results]' \
|
'--token=[specify token to use when uploading]:token' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'--dry-run[perform all checks without uploading]'
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
test)
|
read-manifest)
|
||||||
_arguments \
|
_arguments -s -S $common $manifest
|
||||||
'--features=[space separated feature list]' \
|
;;
|
||||||
'--all-features[enable all available features]' \
|
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
|
||||||
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
|
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
|
||||||
'--test=[test name]: :_test_names' \
|
|
||||||
'--no-default-features[do not build the default features]' \
|
|
||||||
'--no-fail-fast[run all tests regardless of failure]' \
|
|
||||||
'--no-run[compile but do not run]' \
|
|
||||||
'(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
|
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
|
||||||
'--release[build artifacts in release mode, with optimizations]' \
|
|
||||||
'--target=[target triple]' \
|
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
'1: :_test_names' \
|
|
||||||
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
|
||||||
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
|
||||||
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
|
||||||
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
|
||||||
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
|
||||||
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
|
||||||
'--message-format:error format:(human json short)' \
|
|
||||||
'--frozen[require lock and cache up to date]' \
|
|
||||||
'--locked[require lock up to date]'
|
|
||||||
;;
|
|
||||||
|
|
||||||
uninstall)
|
run)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'--bin=[only uninstall the binary NAME]' \
|
'--example=[name of the bin target]:name' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'--bin=[name of the bin target]:name' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'(-p --package)'{-p+,--package=}'[specify package with the target to run]:package:_cargo_package_names' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
|
'--release[build in release mode]' \
|
||||||
'--root=[directory to uninstall packages from]: :_files -/' \
|
'*: :_default'
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
update)
|
rustc)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'--aggressive=[force dependency update]' \
|
'(-p --package)'{-p+,--package=}'[specify package to build]:package:_cargo_package_names' \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--profile=[specify profile to build the selected target for]:profile' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
'--release[build artifacts in release mode, with optimizations]' \
|
||||||
'(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
|
"${command_scope_spec[@]}" \
|
||||||
'--precise=[update single dependency to PRECISE]: :' \
|
'*: : _dispatch rustc rustc -default-'
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
;;
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
|
||||||
'--color=:colorization option:(auto always never)' \
|
|
||||||
;;
|
|
||||||
|
|
||||||
verify-project)
|
rustdoc)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--document-private-items[include non-public items in the documentation]' \
|
||||||
'--manifest-path=[path to manifest]: :_files -/' \
|
'--open[open the docs in a browser after the operation]' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'(-p --package)'{-p+,--package=}'[specify package to document]:package:_cargo_package_names' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--release[build artifacts in release mode, with optimizations]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
"${command_scope_spec[@]}" \
|
||||||
;;
|
'*: : _dispatch rustdoc rustdoc -default-'
|
||||||
|
;;
|
||||||
|
|
||||||
version)
|
search)
|
||||||
_arguments \
|
_arguments -s -S $common $registry \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--index=[specify registry index]:index' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--limit=[limit the number of results]:results [10]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'*: :_guard "^-*" "query"'
|
||||||
;;
|
;;
|
||||||
|
|
||||||
yank)
|
test)
|
||||||
_arguments \
|
_arguments -s -S $common $parallel $features $msgfmt $triple $target $manifest \
|
||||||
'(-h, --help)'{-h,--help}'[show help message]' \
|
'--test=[test name]: :_cargo_test_names' \
|
||||||
'--index[registry index]' \
|
'--no-fail-fast[run all tests regardless of failure]' \
|
||||||
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
|
'--no-run[compile but do not run]' \
|
||||||
'--token[API token to use when authenticating]' \
|
'(-p --package)'{-p+,--package=}'[package to run tests for]:package:_cargo_package_names' \
|
||||||
'--undo[undo a yank, putting a version back into the index]' \
|
'--all[test all packages in the workspace]' \
|
||||||
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
|
'--release[build artifacts in release mode, with optimizations]' \
|
||||||
'--color=:colorization option:(auto always never)' \
|
'1: :_cargo_test_names' \
|
||||||
'--vers[yank version]' \
|
'(--doc --bin --example --test --bench)--lib[only test library]' \
|
||||||
;;
|
'(--lib --bin --example --test --bench)--doc[only test documentation]' \
|
||||||
esac
|
'(--lib --doc --example --test --bench)--bin=[binary name]' \
|
||||||
;;
|
'(--lib --doc --bin --test --bench)--example=[example name]' \
|
||||||
esac
|
'(--lib --doc --bin --example --bench)--test=[test name]' \
|
||||||
|
'(--lib --doc --bin --example --test)--bench=[benchmark name]' \
|
||||||
|
'*: :_default'
|
||||||
|
;;
|
||||||
|
|
||||||
|
uninstall)
|
||||||
|
_arguments -s -S $common \
|
||||||
|
'(-p --package)'{-p+,--package=}'[specify package to uninstall]:package:_cargo_package_names' \
|
||||||
|
'--bin=[only uninstall the specified binary]:name' \
|
||||||
|
'--root=[directory to uninstall packages from]: :_files -/' \
|
||||||
|
'*:crate:_cargo_installed_crates -F line'
|
||||||
|
;;
|
||||||
|
|
||||||
|
update)
|
||||||
|
_arguments -s -S $common $manifest \
|
||||||
|
'--aggressive=[force dependency update]' \
|
||||||
|
"--dry-run[don't actually write the lockfile]" \
|
||||||
|
'(-p --package)'{-p+,--package=}'[specify package to update]:package:_cargo_package_names' \
|
||||||
|
'--precise=[update single dependency to precise release]:release'
|
||||||
|
;;
|
||||||
|
|
||||||
|
verify-project)
|
||||||
|
_arguments -s -S $common $manifest
|
||||||
|
;;
|
||||||
|
|
||||||
|
version)
|
||||||
|
_arguments -s -S $common
|
||||||
|
;;
|
||||||
|
|
||||||
|
yank)
|
||||||
|
_arguments -s -S $common $registry \
|
||||||
|
'--vers=[specify yank version]:version' \
|
||||||
|
'--undo[undo a yank, putting a version back into the index]' \
|
||||||
|
'--index=[specify registry index to yank from]:registry index' \
|
||||||
|
'--token=[specify API token to use when authenticating]:token' \
|
||||||
|
'*: :_guard "^-*" "crate"'
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# allow plugins to define their own functions
|
||||||
|
if ! _call_function ret _cargo-${words[1]}; then
|
||||||
|
# fallback on default completion for unknown commands
|
||||||
|
_default && ret=0
|
||||||
|
fi
|
||||||
|
(( ! ret ))
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
_cargo_cmds(){
|
_cargo_unstable_flags() {
|
||||||
local -a commands;commands=(
|
local flags
|
||||||
'bench:execute all benchmarks of a local package'
|
flags=( help ${${${(M)${(f)"$(_call_program flags cargo -Z help)"}:#*--*}/ #-- #/:}##*-Z } )
|
||||||
'build:compile the current package'
|
_describe -t flags 'unstable flag' flags
|
||||||
'check:check the current package without compiling'
|
|
||||||
'clean:remove generated artifacts'
|
|
||||||
'doc:build package documentation'
|
|
||||||
'fetch:fetch package dependencies'
|
|
||||||
'generate-lockfile:create lockfile'
|
|
||||||
'git-checkout:git checkout'
|
|
||||||
'help:get help for commands'
|
|
||||||
'init:create new package in current directory'
|
|
||||||
'install:install a Rust binary'
|
|
||||||
'locate-project:print "Cargo.toml" location'
|
|
||||||
'login:login to remote server'
|
|
||||||
'metadata:the metadata for a package in json'
|
|
||||||
'new:create a new package'
|
|
||||||
'owner:manage the owners of a crate on the registry'
|
|
||||||
'package:assemble local package into a distributable tarball'
|
|
||||||
'pkgid:print a fully qualified package specification'
|
|
||||||
'publish:upload package to the registry'
|
|
||||||
'read-manifest:print manifest in JSON format'
|
|
||||||
'run:run the main binary of the local package'
|
|
||||||
'rustc:compile a package and all of its dependencies'
|
|
||||||
'rustdoc:build documentation for a package'
|
|
||||||
'search:search packages on crates.io'
|
|
||||||
'test:execute all unit and tests of a local package'
|
|
||||||
'uninstall:remove a Rust binary'
|
|
||||||
'update:update dependencies'
|
|
||||||
'verify-project:check Cargo.toml'
|
|
||||||
'version:show version information'
|
|
||||||
'yank:remove pushed file from index'
|
|
||||||
)
|
|
||||||
_describe -t common-commands 'common commands' commands
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_cargo_all_cmds(){
|
_cargo_installed_crates() {
|
||||||
local -a commands;commands=($(cargo --list))
|
local expl
|
||||||
_describe -t all-commands 'all commands' commands
|
_description crates expl 'crate'
|
||||||
|
compadd "$@" "$expl[@]" - ${${${(f)"$(cargo install --list)"}:# *}%% *}
|
||||||
|
}
|
||||||
|
|
||||||
|
_cargo_cmds() {
|
||||||
|
local -a commands
|
||||||
|
# This uses Parameter Expansion Flags, which are a built-in Zsh feature.
|
||||||
|
# See more: http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion-Flags
|
||||||
|
# and http://zsh.sourceforge.net/Doc/Release/Expansion.html#Parameter-Expansion
|
||||||
|
#
|
||||||
|
# # How this work?
|
||||||
|
#
|
||||||
|
# First it splits the result of `cargo --list` at newline, then it removes the first line.
|
||||||
|
# Then it removes indentation (4 whitespaces) before each items. (Note the x## pattern [1]).
|
||||||
|
# Then it replaces those spaces between item and description with a `:`
|
||||||
|
#
|
||||||
|
# [1]: https://github.com/zsh-users/zsh-completions/blob/master/zsh-completions-howto.org#patterns
|
||||||
|
commands=( ${${${(M)"${(f)$(_call_program commands cargo --list)}":# *}/ ##/}/ ##/:} )
|
||||||
|
_describe -t commands 'command' commands
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#FIXME: Disabled until fixed
|
#FIXME: Disabled until fixed
|
||||||
#gets package names from the manifest file
|
#gets package names from the manifest file
|
||||||
_get_package_names()
|
_cargo_package_names() {
|
||||||
{
|
_message -e packages package
|
||||||
}
|
|
||||||
|
|
||||||
#TODO:see if it makes sense to have 'locate-project' to have non-json output.
|
|
||||||
#strips package name from json stuff
|
|
||||||
_locate_manifest(){
|
|
||||||
local manifest=`cargo locate-project 2>/dev/null`
|
|
||||||
regexp-replace manifest '\{"root":"|"\}' ''
|
|
||||||
echo $manifest
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Extracts the values of "name" from the array given in $1 and shows them as
|
# Extracts the values of "name" from the array given in $1 and shows them as
|
||||||
# command line options for completion
|
# command line options for completion
|
||||||
_get_names_from_array()
|
_cargo_names_from_array() {
|
||||||
{
|
# strip json from the path
|
||||||
local -a filelist;
|
local manifest=${${${"$(cargo locate-project)"}%\"\}}##*\"}
|
||||||
local manifest=$(_locate_manifest)
|
|
||||||
if [[ -z $manifest ]]; then
|
if [[ -z $manifest ]]; then
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
|
@ -494,51 +372,36 @@ _get_names_from_array()
|
||||||
local in_block=false
|
local in_block=false
|
||||||
local block_name=$1
|
local block_name=$1
|
||||||
names=()
|
names=()
|
||||||
while read line
|
while read -r line; do
|
||||||
do
|
|
||||||
if [[ $last_line == "[[$block_name]]" ]]; then
|
if [[ $last_line == "[[$block_name]]" ]]; then
|
||||||
in_block=true
|
in_block=true
|
||||||
else
|
else
|
||||||
if [[ $last_line =~ '.*\[\[.*' ]]; then
|
if [[ $last_line =~ '\s*\[\[.*' ]]; then
|
||||||
in_block=false
|
in_block=false
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $in_block == true ]]; then
|
if [[ $in_block == true ]]; then
|
||||||
if [[ $line =~ '.*name.*=' ]]; then
|
if [[ $line =~ '\s*name\s*=' ]]; then
|
||||||
regexp-replace line '^.*name *= *|"' ""
|
regexp-replace line '^\s*name\s*=\s*|"' ''
|
||||||
names+=$line
|
names+=( "$line" )
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
last_line=$line
|
last_line=$line
|
||||||
done < $manifest
|
done < "$manifest"
|
||||||
_describe $block_name names
|
_describe "$block_name" names
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Gets the test names from the manifest file
|
#Gets the test names from the manifest file
|
||||||
_test_names()
|
_cargo_test_names() {
|
||||||
{
|
_cargo_names_from_array "test"
|
||||||
_get_names_from_array "test"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#Gets the bench names from the manifest file
|
#Gets the bench names from the manifest file
|
||||||
_benchmark_names()
|
_cargo_benchmark_names() {
|
||||||
{
|
_cargo_names_from_array "bench"
|
||||||
_get_names_from_array "bench"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# These flags are mutually exclusive specifiers for the scope of a command; as
|
|
||||||
# they are used in multiple places without change, they are expanded into the
|
|
||||||
# appropriate command's `_arguments` where appropriate.
|
|
||||||
set command_scope_spec
|
|
||||||
command_scope_spec=(
|
|
||||||
'(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
|
|
||||||
'(--bench --bin --test --lib)--example=[example name]'
|
|
||||||
'(--bench --example --test --lib)--bin=[binary name]'
|
|
||||||
'(--bench --bin --example --test)--lib=[library name]'
|
|
||||||
'(--bench --bin --example --lib)--test=[test name]'
|
|
||||||
)
|
|
||||||
|
|
||||||
_cargo
|
_cargo
|
||||||
|
|
Loading…
Reference in a new issue