Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
Oh My Zsh
Commits
8fba5036
Unverified
Commit
8fba5036
authored
Mar 25, 2019
by
Marc Cornellà
Committed by
GitHub
Mar 25, 2019
Browse files
cargo: update completion (#5757)
parents
61a7bc2d
a441f64d
Changes
1
Hide whitespace changes
Inline
Side-by-side
plugins/cargo/_cargo
View file @
8fba5036
#compdef cargo
#compdef cargo
typeset -A opt_args
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
typeset -A opt_args
# leading items in parentheses are an exclusion list for the arguments following that arg
# See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
# - => exclude all other options
# 1 => exclude positional arg 1
# * => exclude all other args
# +blah => exclude +blah
_arguments \
_arguments \
'(- 1 *)'{-h,--help}'[show help message]' \
'(- 1 *)'{-h,--help}'[show help message]' \
'(- 1 *)--list[list installed commands]' \
'(- 1 *)'{-V,--version}'[show version information]' \
'(- 1 *)'{-V,--version}'[show version information]' \
'(- 1 *)'--list'[list installed commands]' \
{-v,--verbose}'[use verbose output]' \
'(- 1 *)'--explain'[Run `rustc --explain CODE`]' \
--color'[colorization option]' \
'(- 1 *)'{-v,--verbose}'[use verbose output]' \
'(+beta +nightly)+stable[use the stable toolchain]' \
'(- 1 *)'--color'[colorization option]' \
'(+stable +nightly)+beta[use the beta toolchain]' \
'(- 1 *)'--frozen'[Require Cargo.lock and cache are up to date]' \
'(+stable +beta)+nightly[use the nightly toolchain]' \
'(- 1 *)'--locked'[Require Cargo.lock is up to date]' \
'1: :->command' \
'1: :_cargo_cmds' \
'*:: :->args'
'*:: :->args'
case $state in
case $state in
command)
_alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
;;
args)
args)
case $words[1] in
case $words[1] in
bench)
bench)
...
@@ -54,6 +68,23 @@ case $state in
...
@@ -54,6 +68,23 @@ case $state in
'--color=:colorization option:(auto always never)' \
'--color=:colorization option:(auto always never)' \
;;
;;
check)
_arguments \
'--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 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)
clean)
_arguments \
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
...
@@ -105,7 +136,7 @@ case $state in
...
@@ -105,7 +136,7 @@ case $state in
git-checkout)
git-checkout)
_arguments \
_arguments \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'
q
(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--reference=[REF]' \
'--reference=[REF]' \
'--url=[URL]' \
'--url=[URL]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
...
@@ -142,10 +173,10 @@ case $state in
...
@@ -142,10 +173,10 @@ case $state in
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
'--no-default-features[do not build the default features]' \
'--no-default-features[do not build the default features]' \
'--path=[local filesystem path to crate to install]' \
'--path=[local filesystem path to crate to install]
: :_files -/
' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
'--rev=[specific commit to use when installing from git]' \
'--rev=[specific commit to use when installing from git]' \
'--root=[directory to install packages into]' \
'--root=[directory to install packages into]
: :_files -/
' \
'--tag=[tag to use when installing from git]' \
'--tag=[tag to use when installing from git]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--vers=[version to install from crates.io]' \
'--vers=[version to install from crates.io]' \
...
@@ -270,7 +301,7 @@ case $state in
...
@@ -270,7 +301,7 @@ case $state in
'--all-features[enable all available features]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to fetch dependencies for]' \
'--manifest-path=[path to the manifest to fetch dependencies for]
: :_files -/
' \
'--no-default-features[do not compile default features for the package]' \
'--no-default-features[do not compile default features for the package]' \
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
'(-p, --package)'{-p,--package}'=[profile to compile for]' \
'--profile=[profile to build the selected target for]' \
'--profile=[profile to build the selected target for]' \
...
@@ -288,7 +319,7 @@ case $state in
...
@@ -288,7 +319,7 @@ case $state in
'--all-features[enable all available features]' \
'--all-features[enable all available features]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
'--manifest-path=[path to the manifest to document]' \
'--manifest-path=[path to the manifest to document]
: :_files -/
' \
'--no-default-features[do not build the `default` feature]' \
'--no-default-features[do not build the `default` feature]' \
'--open[open the docs in a browser after the operation]' \
'--open[open the docs in a browser after the operation]' \
'(-p, --package)'{-p,--package}'=[package to document]' \
'(-p, --package)'{-p,--package}'=[package to document]' \
...
@@ -327,6 +358,15 @@ case $state in
...
@@ -327,6 +358,15 @@ case $state in
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'--color=:colorization option:(auto always never)' \
'--color=:colorization option:(auto always never)' \
'1: :_test_names' \
'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)
uninstall)
...
@@ -335,7 +375,7 @@ case $state in
...
@@ -335,7 +375,7 @@ case $state in
'--color=:colorization option:(auto always never)' \
'--color=:colorization option:(auto always never)' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-h, --help)'{-h,--help}'[show help message]' \
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
'(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
'--root=[directory to uninstall packages from]' \
'--root=[directory to uninstall packages from]
: :_files -/
' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
'(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
;;
;;
...
@@ -386,19 +426,20 @@ esac
...
@@ -386,19 +426,20 @@ esac
_cargo_cmds(){
_cargo_cmds(){
local -a commands;commands=(
local -a commands;commands=(
'bench:execute all benchmarks of a local package'
'bench:execute all benchmarks of a local package'
'build:compile the current project'
'build:compile the current package'
'check:check the current package without compiling'
'clean:remove generated artifacts'
'clean:remove generated artifacts'
'doc:build package documentation'
'doc:build package documentation'
'fetch:fetch package dependencies'
'fetch:fetch package dependencies'
'generate-lockfile:create lockfile'
'generate-lockfile:create lockfile'
'git-checkout:git checkout'
'git-checkout:git checkout'
'help:get help for commands'
'help:get help for commands'
'init:create new p
roject
in current directory'
'init:create new p
ackage
in current directory'
'install:install a Rust binary'
'install:install a Rust binary'
'locate-project:print "Cargo.toml" location'
'locate-project:print "Cargo.toml" location'
'login:login to remote server'
'login:login to remote server'
'metadata:the metadata for a p
roject
in json'
'metadata:the metadata for a p
ackage
in json'
'new:create a new p
roject
'
'new:create a new p
ackage
'
'owner:manage the owners of a crate on the registry'
'owner:manage the owners of a crate on the registry'
'package:assemble local package into a distributable tarball'
'package:assemble local package into a distributable tarball'
'pkgid:print a fully qualified package specification'
'pkgid:print a fully qualified package specification'
...
@@ -415,8 +456,12 @@ local -a commands;commands=(
...
@@ -415,8 +456,12 @@ local -a commands;commands=(
'version:show version information'
'version:show version information'
'yank:remove pushed file from index'
'yank:remove pushed file from index'
)
)
_describe 'command' commands
_describe -t common-commands 'common commands' commands
}
_cargo_all_cmds(){
local -a commands;commands=($(cargo --list))
_describe -t all-commands 'all commands' commands
}
}
...
@@ -484,7 +529,7 @@ _benchmark_names()
...
@@ -484,7 +529,7 @@ _benchmark_names()
_get_names_from_array "bench"
_get_names_from_array "bench"
}
}
# These flags are mutally exclusive specifiers for the scope of a command; as
# These flags are mut
u
ally exclusive specifiers for the scope of a command; as
# they are used in multiple places without change, they are expanded into the
# they are used in multiple places without change, they are expanded into the
# appropriate command's `_arguments` where appropriate.
# appropriate command's `_arguments` where appropriate.
set command_scope_spec
set command_scope_spec
...
@@ -496,5 +541,4 @@ command_scope_spec=(
...
@@ -496,5 +541,4 @@ command_scope_spec=(
'(--bench --bin --example --lib)--test=[test name]'
'(--bench --bin --example --lib)--test=[test name]'
)
)
_cargo
_cargo
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment