_cargo 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544
  1. #compdef cargo
  2. autoload -U regexp-replace
  3. zstyle -T ':completion:*:*:cargo:*' tag-order && \
  4. zstyle ':completion:*:*:cargo:*' tag-order 'common-commands'
  5. _cargo() {
  6. local context state state_descr line
  7. typeset -A opt_args
  8. # leading items in parentheses are an exclusion list for the arguments following that arg
  9. # See: http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-Functions
  10. # - => exclude all other options
  11. # 1 => exclude positional arg 1
  12. # * => exclude all other args
  13. # +blah => exclude +blah
  14. _arguments \
  15. '(- 1 *)'{-h,--help}'[show help message]' \
  16. '(- 1 *)--list[list installed commands]' \
  17. '(- 1 *)'{-V,--version}'[show version information]' \
  18. {-v,--verbose}'[use verbose output]' \
  19. --color'[colorization option]' \
  20. '(+beta +nightly)+stable[use the stable toolchain]' \
  21. '(+stable +nightly)+beta[use the beta toolchain]' \
  22. '(+stable +beta)+nightly[use the nightly toolchain]' \
  23. '1: :->command' \
  24. '*:: :->args'
  25. case $state in
  26. command)
  27. _alternative 'common-commands:common:_cargo_cmds' 'all-commands:all:_cargo_all_cmds'
  28. ;;
  29. args)
  30. case $words[1] in
  31. bench)
  32. _arguments \
  33. '--features=[space separated feature list]' \
  34. '--all-features[enable all available features]' \
  35. '(-h, --help)'{-h,--help}'[show help message]' \
  36. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  37. "${command_scope_spec[@]}" \
  38. '--manifest-path=[path to manifest]: :_files -/' \
  39. '--no-default-features[do not build the default features]' \
  40. '--no-run[compile but do not run]' \
  41. '(-p,--package)'{-p=,--package=}'[package to run benchmarks for]:packages:_get_package_names' \
  42. '--target=[target triple]' \
  43. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  44. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  45. '--color=:colorization option:(auto always never)' \
  46. ;;
  47. build)
  48. _arguments \
  49. '--features=[space separated feature list]' \
  50. '--all-features[enable all available features]' \
  51. '(-h, --help)'{-h,--help}'[show help message]' \
  52. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  53. "${command_scope_spec[@]}" \
  54. '--manifest-path=[path to manifest]: :_files -/' \
  55. '--no-default-features[do not build the default features]' \
  56. '(-p,--package)'{-p=,--package=}'[package to build]:packages:_get_package_names' \
  57. '--release=[build in release mode]' \
  58. '--target=[target triple]' \
  59. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  60. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  61. '--color=:colorization option:(auto always never)' \
  62. ;;
  63. check)
  64. _arguments \
  65. '--features=[space separated feature list]' \
  66. '--all-features[enable all available features]' \
  67. '(-h, --help)'{-h,--help}'[show help message]' \
  68. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  69. "${command_scope_spec[@]}" \
  70. '--manifest-path=[path to manifest]: :_files -/' \
  71. '--no-default-features[do not check the default features]' \
  72. '(-p,--package)'{-p=,--package=}'[package to check]:packages:_get_package_names' \
  73. '--release=[check in release mode]' \
  74. '--target=[target triple]' \
  75. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  76. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  77. '--color=:colorization option:(auto always never)' \
  78. ;;
  79. clean)
  80. _arguments \
  81. '(-h, --help)'{-h,--help}'[show help message]' \
  82. '--manifest-path=[path to manifest]: :_files -/' \
  83. '(-p,--package)'{-p=,--package=}'[package to clean]:packages:_get_package_names' \
  84. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  85. '--release[whether or not to clean release artifacts]' \
  86. '--target=[target triple(default:all)]' \
  87. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  88. '--color=:colorization option:(auto always never)' \
  89. ;;
  90. doc)
  91. _arguments \
  92. '--features=[space separated feature list]' \
  93. '--all-features[enable all available features]' \
  94. '(-h, --help)'{-h,--help}'[show help message]' \
  95. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  96. '--manifest-path=[path to manifest]: :_files -/' \
  97. '--no-deps[do not build docs for dependencies]' \
  98. '--no-default-features[do not build the default features]' \
  99. '--open[open docs in browser after the build]' \
  100. '(-p, --package)'{-p,--package}'=[package to document]' \
  101. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  102. '--release[build artifacts in release mode, with optimizations]' \
  103. '--target=[build for the target triple]' \
  104. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  105. '--color=:colorization option:(auto always never)' \
  106. ;;
  107. fetch)
  108. _arguments \
  109. '(-h, --help)'{-h,--help}'[show help message]' \
  110. '--manifest-path=[path to manifest]: :_files -/' \
  111. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  112. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  113. '--color=:colorization option:(auto always never)' \
  114. ;;
  115. generate-lockfile)
  116. _arguments \
  117. '(-h, --help)'{-h,--help}'[show help message]' \
  118. '--manifest-path=[path to manifest]: :_files -/' \
  119. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  120. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  121. '--color=:colorization option:(auto always never)' \
  122. ;;
  123. git-checkout)
  124. _arguments \
  125. '(-h, --help)'{-h,--help}'[show help message]' \
  126. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  127. '--reference=[REF]' \
  128. '--url=[URL]' \
  129. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  130. '--color=:colorization option:(auto always never)' \
  131. ;;
  132. help)
  133. _arguments \
  134. '(-h, --help)'{-h,--help}'[show help message]' \
  135. '*: :_cargo_cmds' \
  136. ;;
  137. init)
  138. _arguments \
  139. '--bin[use binary template]' \
  140. '--vcs:initialize a new repo with a given VCS:(git hg none)' \
  141. '(-h, --help)'{-h,--help}'[show help message]' \
  142. '--name=[set the resulting package name]' \
  143. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  144. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  145. '--color=:colorization option:(auto always never)' \
  146. ;;
  147. install)
  148. _arguments \
  149. '--bin=[only install the specified binary]' \
  150. '--branch=[branch to use when installing from git]' \
  151. '--color=:colorization option:(auto always never)' \
  152. '--debug[build in debug mode instead of release mode]' \
  153. '--example[install the specified example instead of binaries]' \
  154. '--features=[space separated feature list]' \
  155. '--all-features[enable all available features]' \
  156. '--git=[URL from which to install the crate]' \
  157. '(-h, --help)'{-h,--help}'[show help message]' \
  158. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  159. '--no-default-features[do not build the default features]' \
  160. '--path=[local filesystem path to crate to install]: :_files -/' \
  161. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  162. '--rev=[specific commit to use when installing from git]' \
  163. '--root=[directory to install packages into]: :_files -/' \
  164. '--tag=[tag to use when installing from git]' \
  165. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  166. '--vers=[version to install from crates.io]' \
  167. ;;
  168. locate-project)
  169. _arguments \
  170. '(-h, --help)'{-h,--help}'[show help message]' \
  171. '--manifest-path=[path to manifest]: :_files -/' \
  172. ;;
  173. login)
  174. _arguments \
  175. '(-h, --help)'{-h,--help}'[show help message]' \
  176. '--host=[Host to set the token for]' \
  177. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  178. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  179. '--color=:colorization option:(auto always never)' \
  180. ;;
  181. metadata)
  182. _arguments \
  183. '(-h, --help)'{-h,--help}'[show help message]' \
  184. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  185. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  186. "--no-deps[output information only about the root package and don't fetch dependencies]" \
  187. '--no-default-features[do not include the default feature]' \
  188. '--manifest-path=[path to manifest]: :_files -/' \
  189. '--features=[space separated feature list]' \
  190. '--all-features[enable all available features]' \
  191. '--format-version=[format version(default: 1)]' \
  192. '--color=:colorization option:(auto always never)' \
  193. ;;
  194. new)
  195. _arguments \
  196. '--bin[use binary template]' \
  197. '--vcs:initialize a new repo with a given VCS:(git hg none)' \
  198. '(-h, --help)'{-h,--help}'[show help message]' \
  199. '--name=[set the resulting package name]' \
  200. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  201. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  202. '--color=:colorization option:(auto always never)' \
  203. ;;
  204. owner)
  205. _arguments \
  206. '(-a, --add)'{-a,--add}'[add owner LOGIN]' \
  207. '(-h, --help)'{-h,--help}'[show help message]' \
  208. '--index[registry index]' \
  209. '(-l, --list)'{-l,--list}'[list owners of a crate]' \
  210. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  211. '(-r, --remove)'{-r,--remove}'[remove owner LOGIN]' \
  212. '--token[API token to use when authenticating]' \
  213. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  214. '--color=:colorization option:(auto always never)' \
  215. ;;
  216. package)
  217. _arguments \
  218. '(-h, --help)'{-h,--help}'[show help message]' \
  219. '(-l, --list)'{-l,--list}'[print files included in a package without making one]' \
  220. '--manifest-path=[path to manifest]: :_files -/' \
  221. '--no-metadata[ignore warnings about a lack of human-usable metadata]' \
  222. '--no-verify[do not build to verify contents]' \
  223. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  224. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  225. '--color=:colorization option:(auto always never)' \
  226. ;;
  227. pkgid)
  228. _arguments \
  229. '(-h, --help)'{-h,--help}'[show help message]' \
  230. '--manifest-path=[path to manifest]: :_files -/' \
  231. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  232. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  233. '--color=:colorization option:(auto always never)' \
  234. ;;
  235. publish)
  236. _arguments \
  237. '(-h, --help)'{-h,--help}'[show help message]' \
  238. '--host=[Host to set the token for]' \
  239. '--manifest-path=[path to manifest]: :_files -/' \
  240. '--no-verify[Do not verify tarball until before publish]' \
  241. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  242. '--token[token to use when uploading]' \
  243. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  244. '--color=:colorization option:(auto always never)' \
  245. ;;
  246. read-manifest)
  247. _arguments \
  248. '(-h, --help)'{-h,--help}'[show help message]' \
  249. '--manifest-path=[path to manifest]: :_files -/' \
  250. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  251. '--color=:colorization option:(auto always never)' \
  252. ;;
  253. run)
  254. _arguments \
  255. '--example=[name of the bin target]' \
  256. '--features=[space separated feature list]' \
  257. '--all-features[enable all available features]' \
  258. '(-h, --help)'{-h,--help}'[show help message]' \
  259. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  260. '--manifest-path=[path to manifest]: :_files -/' \
  261. '--bin=[name of the bin target]' \
  262. '--no-default-features[do not build the default features]' \
  263. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  264. '--release=[build in release mode]' \
  265. '--target=[target triple]' \
  266. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  267. '--color=:colorization option:(auto always never)' \
  268. '*: :_normal' \
  269. ;;
  270. rustc)
  271. _arguments \
  272. '--color=:colorization option:(auto always never)' \
  273. '--features=[features to compile for the package]' \
  274. '--all-features[enable all available features]' \
  275. '(-h, --help)'{-h,--help}'[show help message]' \
  276. '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
  277. '--manifest-path=[path to the manifest to fetch dependencies for]: :_files -/' \
  278. '--no-default-features[do not compile default features for the package]' \
  279. '(-p, --package)'{-p,--package}'=[profile to compile for]' \
  280. '--profile=[profile to build the selected target for]' \
  281. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  282. '--release[build artifacts in release mode, with optimizations]' \
  283. '--target=[target triple which compiles will be for]' \
  284. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  285. "${command_scope_spec[@]}" \
  286. ;;
  287. rustdoc)
  288. _arguments \
  289. '--color=:colorization option:(auto always never)' \
  290. '--features=[space-separated list of features to also build]' \
  291. '--all-features[enable all available features]' \
  292. '(-h, --help)'{-h,--help}'[show help message]' \
  293. '(-j, --jobs)'{-j,--jobs}'=[number of parallel jobs, defaults to # of CPUs]' \
  294. '--manifest-path=[path to the manifest to document]: :_files -/' \
  295. '--no-default-features[do not build the `default` feature]' \
  296. '--open[open the docs in a browser after the operation]' \
  297. '(-p, --package)'{-p,--package}'=[package to document]' \
  298. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  299. '--release[build artifacts in release mode, with optimizations]' \
  300. '--target=[build for the target triple]' \
  301. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  302. "${command_scope_spec[@]}" \
  303. ;;
  304. search)
  305. _arguments \
  306. '--color=:colorization option:(auto always never)' \
  307. '(-h, --help)'{-h,--help}'[show help message]' \
  308. '--host=[host of a registry to search in]' \
  309. '--limit=[limit the number of results]' \
  310. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  311. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  312. ;;
  313. test)
  314. _arguments \
  315. '--features=[space separated feature list]' \
  316. '--all-features[enable all available features]' \
  317. '(-h, --help)'{-h,--help}'[show help message]' \
  318. '(-j, --jobs)'{-j,--jobs}'[number of parallel jobs, defaults to # of CPUs]' \
  319. '--manifest-path=[path to manifest]: :_files -/' \
  320. '--test=[test name]: :_test_names' \
  321. '--no-default-features[do not build the default features]' \
  322. '--no-fail-fast[run all tests regardless of failure]' \
  323. '--no-run[compile but do not run]' \
  324. '(-p,--package)'{-p=,--package=}'[package to run tests for]:packages:_get_package_names' \
  325. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  326. '--release[build artifacts in release mode, with optimizations]' \
  327. '--target=[target triple]' \
  328. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  329. '--color=:colorization option:(auto always never)' \
  330. '1: :_test_names' \
  331. '(--doc --bin --example --test --bench)--lib[only test library]' \
  332. '(--lib --bin --example --test --bench)--doc[only test documentation]' \
  333. '(--lib --doc --example --test --bench)--bin=[binary name]' \
  334. '(--lib --doc --bin --test --bench)--example=[example name]' \
  335. '(--lib --doc --bin --example --bench)--test=[test name]' \
  336. '(--lib --doc --bin --example --test)--bench=[benchmark name]' \
  337. '--message-format:error format:(human json short)' \
  338. '--frozen[require lock and cache up to date]' \
  339. '--locked[require lock up to date]'
  340. ;;
  341. uninstall)
  342. _arguments \
  343. '--bin=[only uninstall the binary NAME]' \
  344. '--color=:colorization option:(auto always never)' \
  345. '(-h, --help)'{-h,--help}'[show help message]' \
  346. '(-q, --quiet)'{-q,--quiet}'[less output printed to stdout]' \
  347. '--root=[directory to uninstall packages from]: :_files -/' \
  348. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  349. ;;
  350. update)
  351. _arguments \
  352. '--aggressive=[force dependency update]' \
  353. '(-h, --help)'{-h,--help}'[show help message]' \
  354. '--manifest-path=[path to manifest]: :_files -/' \
  355. '(-p,--package)'{-p=,--package=}'[package to update]:packages:__get_package_names' \
  356. '--precise=[update single dependency to PRECISE]: :' \
  357. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  358. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  359. '--color=:colorization option:(auto always never)' \
  360. ;;
  361. verify-project)
  362. _arguments \
  363. '(-h, --help)'{-h,--help}'[show help message]' \
  364. '--manifest-path=[path to manifest]: :_files -/' \
  365. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  366. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  367. '--color=:colorization option:(auto always never)' \
  368. ;;
  369. version)
  370. _arguments \
  371. '(-h, --help)'{-h,--help}'[show help message]' \
  372. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  373. '--color=:colorization option:(auto always never)' \
  374. ;;
  375. yank)
  376. _arguments \
  377. '(-h, --help)'{-h,--help}'[show help message]' \
  378. '--index[registry index]' \
  379. '(-q, --quiet)'{-q,--quiet}'[no output printed to stdout]' \
  380. '--token[API token to use when authenticating]' \
  381. '--undo[undo a yank, putting a version back into the index]' \
  382. '(-v, --verbose)'{-v,--verbose}'[use verbose output]' \
  383. '--color=:colorization option:(auto always never)' \
  384. '--vers[yank version]' \
  385. ;;
  386. esac
  387. ;;
  388. esac
  389. }
  390. _cargo_cmds(){
  391. local -a commands;commands=(
  392. 'bench:execute all benchmarks of a local package'
  393. 'build:compile the current package'
  394. 'check:check the current package without compiling'
  395. 'clean:remove generated artifacts'
  396. 'doc:build package documentation'
  397. 'fetch:fetch package dependencies'
  398. 'generate-lockfile:create lockfile'
  399. 'git-checkout:git checkout'
  400. 'help:get help for commands'
  401. 'init:create new package in current directory'
  402. 'install:install a Rust binary'
  403. 'locate-project:print "Cargo.toml" location'
  404. 'login:login to remote server'
  405. 'metadata:the metadata for a package in json'
  406. 'new:create a new package'
  407. 'owner:manage the owners of a crate on the registry'
  408. 'package:assemble local package into a distributable tarball'
  409. 'pkgid:print a fully qualified package specification'
  410. 'publish:upload package to the registry'
  411. 'read-manifest:print manifest in JSON format'
  412. 'run:run the main binary of the local package'
  413. 'rustc:compile a package and all of its dependencies'
  414. 'rustdoc:build documentation for a package'
  415. 'search:search packages on crates.io'
  416. 'test:execute all unit and tests of a local package'
  417. 'uninstall:remove a Rust binary'
  418. 'update:update dependencies'
  419. 'verify-project:check Cargo.toml'
  420. 'version:show version information'
  421. 'yank:remove pushed file from index'
  422. )
  423. _describe -t common-commands 'common commands' commands
  424. }
  425. _cargo_all_cmds(){
  426. local -a commands;commands=($(cargo --list))
  427. _describe -t all-commands 'all commands' commands
  428. }
  429. #FIXME: Disabled until fixed
  430. #gets package names from the manifest file
  431. _get_package_names()
  432. {
  433. }
  434. #TODO:see if it makes sense to have 'locate-project' to have non-json output.
  435. #strips package name from json stuff
  436. _locate_manifest(){
  437. local manifest=`cargo locate-project 2>/dev/null`
  438. regexp-replace manifest '\{"root":"|"\}' ''
  439. echo $manifest
  440. }
  441. # Extracts the values of "name" from the array given in $1 and shows them as
  442. # command line options for completion
  443. _get_names_from_array()
  444. {
  445. local -a filelist;
  446. local manifest=$(_locate_manifest)
  447. if [[ -z $manifest ]]; then
  448. return 0
  449. fi
  450. local last_line
  451. local -a names;
  452. local in_block=false
  453. local block_name=$1
  454. names=()
  455. while read line
  456. do
  457. if [[ $last_line == "[[$block_name]]" ]]; then
  458. in_block=true
  459. else
  460. if [[ $last_line =~ '.*\[\[.*' ]]; then
  461. in_block=false
  462. fi
  463. fi
  464. if [[ $in_block == true ]]; then
  465. if [[ $line =~ '.*name.*=' ]]; then
  466. regexp-replace line '^.*name *= *|"' ""
  467. names+=$line
  468. fi
  469. fi
  470. last_line=$line
  471. done < $manifest
  472. _describe $block_name names
  473. }
  474. #Gets the test names from the manifest file
  475. _test_names()
  476. {
  477. _get_names_from_array "test"
  478. }
  479. #Gets the bench names from the manifest file
  480. _benchmark_names()
  481. {
  482. _get_names_from_array "bench"
  483. }
  484. # These flags are mutually exclusive specifiers for the scope of a command; as
  485. # they are used in multiple places without change, they are expanded into the
  486. # appropriate command's `_arguments` where appropriate.
  487. set command_scope_spec
  488. command_scope_spec=(
  489. '(--bin --example --test --lib)--bench=[benchmark name]: :_benchmark_names'
  490. '(--bench --bin --test --lib)--example=[example name]'
  491. '(--bench --example --test --lib)--bin=[binary name]'
  492. '(--bench --bin --example --test)--lib=[library name]'
  493. '(--bench --bin --example --lib)--test=[test name]'
  494. )
  495. _cargo