_cargo 25 KB

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