zsh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619
  1. #compdef yay
  2. # vim:fdm=marker foldlevel=0 tabstop=2 shiftwidth=2 filetype=zsh
  3. typeset -A opt_args
  4. setopt extendedglob
  5. # options for passing to _arguments: main pacman commands
  6. _pacman_opts_commands=(
  7. {-D,--database}'[Modify database]'
  8. {-F,--files}'[Query the files database]'
  9. {-G,--getpkgbuild}'[Get PKGBUILD from ABS or AUR]'
  10. {-Q,--query}'[Query the package database]'
  11. {-R,--remove}'[Remove a package from the system]'
  12. {-P,--show}'[Print yay information]'
  13. {-S,--sync}'[Synchronize packages]'
  14. {-T,--deptest}'[Check if dependencies are installed]'
  15. {-U,--upgrade}'[Upgrade a package]'
  16. {-Y,--yay}'[Yay specific options]'
  17. {-V,--version}'[Display version and exit]'
  18. '(-h --help)'{-h,--help}'[Display usage]'
  19. )
  20. # options for passing to _arguments: options common to all commands
  21. _pacman_opts_common=(
  22. '--repo[Assume targets are from the repositories]'
  23. {-a,--aur}'[Assume targets are from the AUR]'
  24. '--aururl[Set an alternative AUR URL]:url'
  25. '--arch[Set an alternate architecture]'
  26. {-b,--dbpath}'[Alternate database location]:database_location:_files -/'
  27. '--color[colorize the output]:color options:(always never auto)'
  28. {-h,--help}'[Display syntax for the given operation]'
  29. {-r,--root}'[Set alternate installation root]:installation root:_files -/'
  30. {-v,--verbose}'[Be more verbose]'
  31. '--cachedir[Alternate package cache location]:cache_location:_files -/'
  32. '--config[An alternate configuration file]:config file:_files'
  33. '--makepkgconf[makepkg.conf file to use]:config file:_files'
  34. '--nomakepkgconf[Use the default makepkg.conf]'
  35. '--requestsplitn[Max amount of packages to query per AUR request]:number'
  36. '--completioninterval[Time in days to refresh completion cache]:number'
  37. '--confirm[Always ask for confirmation]'
  38. '--debug[Display debug messages]'
  39. '--gpgdir[Set an alternate directory for GnuPG (instead of /etc/pacman.d/gnupg)]: :_files -/'
  40. '--hookdir[Set an alternate hook location]: :_files -/'
  41. '--logfile[An alternate log file]:config file:_files'
  42. '--noconfirm[Do not ask for confirmation]'
  43. '--noprogressbar[Do not show a progress bar when downloading files]'
  44. '--noscriptlet[Do not execute the install scriptlet if one exists]'
  45. '--save[Causes config options to be saved back to the config file]'
  46. '--builddir[Directory to use for building AUR Packages]:build dir:_files -/'
  47. '--editor[Editor to use when editing PKGBUILDs]:editor:_files'
  48. '--editorflags[Flags to pass to editor]'
  49. '--makepkg[makepkg command to use]:makepkg:_files'
  50. '--pacman[pacman command to use]:pacman:_files'
  51. '--git[git command to use]:git:_files'
  52. '--gpg[gpg command to use]:gpg:_files'
  53. '--sortby[Sort AUR results by a specific field during search]:sortby options:(votes popularity id baseid name base submitted modified)'
  54. '--answerclean[Set a predetermined answer for the clean build menu]:answer'
  55. '--answerdiff[Set a predetermined answer for the diff menu]:answer'
  56. '--answeredit[Set a predetermined answer for the edit pkgbuild menu]:answer'
  57. '--answerupgrade[Set a predetermined answer for the upgrade menu]:answer'
  58. '--noanswerclean[Unset the answer for the clean build menu]'
  59. '--noanswerdiff[Unset the answer for the diff menu]'
  60. '--noansweredit[Unset the answer for the edit pkgbuild menu]'
  61. '--noanswerupgrade[Unset the answer for the upgrade menu]'
  62. '--cleanmenu[Give the option to clean build PKGBUILDS]'
  63. '--diffmenu[Give the option to show diffs for build files]'
  64. '--editmenu[Give the option to edit/view PKGBUILDS]'
  65. '--upgrademenu[Show a detailed list of updates with the option to skip any]'
  66. "--nocleanmenu[Don't clean build PKGBUILDS]"
  67. "--nodiffmenu[Don't show diffs for build files]"
  68. "--noeditmenu[Don't edit/view PKGBUILDS]"
  69. "--noupgrademenu[Don't show the upgrade menu]"
  70. "--askremovemake[Ask to remove makedepends after install]"
  71. "--removemake[Remove makedepends after install]"
  72. "--noremovemake[Don't remove makedepends after install]"
  73. '--bottomup[Show AUR packages first]'
  74. '--topdown[Show repository packages first]'
  75. '--singlelineresults[List each search result on its own line]'
  76. '--doublelineresults[List each search result on two lines, like pacman]'
  77. '--devel[Check -git/-svn/-hg development version]'
  78. '--nodevel[Disable development version checking]'
  79. '--cleanafter[Clean package sources after successful build]'
  80. '--nocleanafter[Disable package sources cleaning after successful build]'
  81. '--timeupdate[Check packages modification date and version]'
  82. '--notimeupdate[Check only package version change]'
  83. '--redownload[Always download pkgbuilds of targets]'
  84. '--redownloadall[Always download pkgbuilds of all AUR packages]'
  85. '--noredownload[Skip pkgbuild download if in cache and up to date]'
  86. '--rebuild[Always build target packages]'
  87. '--rebuildall[Always build all AUR packages]'
  88. '--provides[Look for matching providers when searching for packages]'
  89. '--noprovides[Just look for packages by pkgname]'
  90. '--pgpfetch[Prompt to import PGP keys from PKGBUILDs]'
  91. "--nopgpfetch[Don't prompt to import PGP keys]"
  92. "--useask[Automatically resolve conflicts using pacman's ask flag]"
  93. '--nouseask[Confirm conflicts manually during the install]'
  94. '--combinedupgrade[Refresh then perform the repo and AUR upgrade together]'
  95. '--nocombinedupgrade[Perform the repo upgrade and AUR upgrade separately]'
  96. '--rebuildtree[Always build all AUR packages even if installed]'
  97. '--norebuild[Skip package build if in cache and up to date]'
  98. '--mflags[Pass arguments to makepkg]:mflags'
  99. '--gpgflags[Pass arguments to gpg]:gpgflags'
  100. '--sudoloop[Loop sudo calls in the background to avoid timeout]'
  101. '--nosudoloop[Do not loop sudo calls in the background]'
  102. '--searchby[Search for packages using a specified field]'
  103. '--sortby[Sort AUR results by a specific field during search]'
  104. '--batchinstall[Build multiple AUR packages then install them together]'
  105. '--nobatchinstall[Build and install each AUR package one by one]'
  106. )
  107. # options for passing to _arguments: options for --upgrade commands
  108. _pacman_opts_pkgfile=(
  109. '*-d[Skip dependency checks]'
  110. '*--nodeps[Skip dependency checks]'
  111. '*--assume-installed[Add virtual package to satisfy dependencies]'
  112. '--dbonly[Only remove database entry, do not remove files]'
  113. '--overwrite[Overwrite conflicting files]:file:_files -g "*"'
  114. '--needed[Do not reinstall up to date packages]'
  115. '--asdeps[mark packages as non-explicitly installed]'
  116. '--asexplicit[mark packages as explicitly installed]'
  117. {-p,--print}'[Only print the targets instead of performing the operation]'
  118. '*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
  119. '*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
  120. '--print-format[Specify how the targets should be printed]'
  121. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  122. )
  123. # options for passing to _arguments: subactions for --query command
  124. _pacman_opts_query_actions=(
  125. '(-Q --query)'{-Q,--query}
  126. {-g,--groups}'[View all members of a package group]:*:package groups:->query_group'
  127. {-o,--owns}'[Query the package that owns a file]:file:_files'
  128. {-p,--file}'[Package file to query]:*:package file:->query_file'
  129. {-s,--search}'[Search package names and descriptions]:*:search text:->query_search'
  130. )
  131. # options for passing to _arguments: options for --query and subcommands
  132. _pacman_opts_query_modifiers=(
  133. {-c,--changelog}'[List package changelog]'
  134. {-d,--deps}'[List packages installed as dependencies]'
  135. {-e,--explicit}'[List packages explicitly installed]'
  136. {\*-i,\*--info}'[View package information]'
  137. {\*-k,\*--check}'[Check package files]'
  138. {-l,--list}'[List package contents]'
  139. {-m,--foreign}'[List installed packages not found in sync db(s)]'
  140. {-n,--native}'[List installed packages found in sync db(s)]'
  141. {-q,--quiet}'[Show less information for query and search]'
  142. {-t,--unrequired}'[List packages not required by any package]'
  143. {-u,--upgrades}'[List packages that can be upgraded]'
  144. )
  145. # -Y
  146. _pacman_opts_yay_modifiers=(
  147. {-c,--clean}'[Remove unneeded dependencies]'
  148. '--gendb[Generates development package DB used for updating]'
  149. )
  150. # -G
  151. _pacman_opts_getpkgbuild_modifiers=(
  152. {-f,--force}'[Force download for existing ABS packages]'
  153. {-p,--print}'[Print PKGBUILDs]:package:_pacman_completions_all_packages'
  154. )
  155. # -P
  156. _pacman_opts_print_modifiers=(
  157. {-c,--complete}'[Used for completions]'
  158. {-d,--defaultconfig}'[Print default yay configuration]'
  159. {-g,--config}'[Print current yay configuration]'
  160. {-n,--numberupgrades}'[Print number of updates]'
  161. {-s,--stats}'[Display system package statistics]'
  162. {-u,--upgrades}'[Print update list]'
  163. {-w,--news}'[Print arch news]'
  164. )
  165. # options for passing to _arguments: options for --remove command
  166. _pacman_opts_remove=(
  167. {-c,--cascade}'[Remove all dependent packages]'
  168. {-d,--nodeps}'[Skip dependency checks]'
  169. '*--assume-installed[Add virtual package to satisfy dependencies]'
  170. {-n,--nosave}'[Remove protected configuration files]'
  171. {-p,--print}'[Only print the targets instead of performing the operation]'
  172. {\*-s,\*--recursive}'[Remove dependencies not required by other packages]'
  173. {-u,--unneeded}'[Remove unneeded packages]'
  174. '--dbonly[Only remove database entry, do not remove files]'
  175. '--print-format[Specify how the targets should be printed]'
  176. '*:installed package:_pacman_completions_installed_packages'
  177. )
  178. _pacman_opts_database=(
  179. '--asdeps[mark packages as non-explicitly installed]'
  180. '--asexplicit[mark packages as explicitly installed]'
  181. '*:installed package:_pacman_completions_installed_packages'
  182. )
  183. _pacman_opts_files=(
  184. {-l,--list}'[List the files owned by the queried package]:package:_pacman_completions_all_packages'
  185. {-x,--regex}'[Enable searching using regular expressions]:regex:'
  186. {-y,--refresh}'[Download fresh files databases from the server]'
  187. '--machinereadable[Produce machine-readable output]'
  188. {-q,--quiet}'[Show less information for query and search]'
  189. )
  190. # options for passing to _arguments: options for --sync command
  191. _pacman_opts_sync_actions=(
  192. '(-S --sync)'{-S,--sync}
  193. {\*-c,\*--clean}'[Remove old packages from cache]:\*:clean:->sync_clean'
  194. {-g,--groups}'[View all members of a package group]:*:package groups:->sync_group'
  195. {-s,--search}'[Search package names and descriptions]:*:search text:->sync_search'
  196. '--dbonly[Only remove database entry, do not remove files]'
  197. '--needed[Do not reinstall up to date packages]'
  198. '--recursive[Reinstall all dependencies of target packages]'
  199. )
  200. # options for passing to _arguments: options for --sync command
  201. _pacman_opts_sync_modifiers=(
  202. {\*-d,\*--nodeps}'[Skip dependency checks]'
  203. '*--assume-installed[Add virtual package to satisfy dependencies]'
  204. {\*-i,\*--info}'[View package information]'
  205. {-l,--list}'[List all packages in a repository]'
  206. {-p,--print}'[Print download URIs for each package to be installed]'
  207. {-q,--quiet}'[Show less information for query and search]'
  208. {\*-u,\*--sysupgrade}'[Upgrade all out-of-date packages]'
  209. {-w,--downloadonly}'[Download packages only]'
  210. {\*-y,\*--refresh}'[Download fresh package databases]'
  211. '*--ignore[Ignore a package upgrade]:package: _pacman_completions_all_packages'
  212. '*--ignoregroup[Ignore a group upgrade]:package group:_pacman_completions_all_groups'
  213. '--asdeps[Install packages as non-explicitly installed]'
  214. '--asexplicit[Install packages as explicitly installed]'
  215. '--overwrite[Overwrite conflicting files]:files:_files'
  216. '--print-format[Specify how the targets should be printed]'
  217. )
  218. # handles --help subcommand
  219. _pacman_action_help() {
  220. _arguments -s : \
  221. "$_pacman_opts_commands[@]"
  222. }
  223. # handles cases where no subcommand has yet been given
  224. _pacman_action_none() {
  225. _arguments -s : \
  226. "$_pacman_opts_commands[@]"
  227. }
  228. # handles --query subcommand
  229. _pacman_action_query() {
  230. local context state line
  231. typeset -A opt_args
  232. case $state in
  233. query_file)
  234. _arguments -s : \
  235. "$_pacman_opts_common[@]" \
  236. "$_pacman_opts_query_modifiers[@]" \
  237. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  238. ;;
  239. query_group)
  240. _arguments -s : \
  241. "$_pacman_opts_common[@]" \
  242. "$_pacman_opts_query_modifiers[@]" \
  243. '*:groups:_pacman_completions_installed_groups'
  244. ;;
  245. query_owner)
  246. _arguments -s : \
  247. "$_pacman_opts_common[@]" \
  248. "$_pacman_opts_query_modifiers[@]" \
  249. '*:file:_files'
  250. ;;
  251. query_search)
  252. _arguments -s : \
  253. "$_pacman_opts_common[@]" \
  254. "$_pacman_opts_query_modifiers[@]" \
  255. '*:search text: '
  256. ;;
  257. *)
  258. _arguments -s : \
  259. "$_pacman_opts_common[@]" \
  260. "$_pacman_opts_query_actions[@]" \
  261. "$_pacman_opts_query_modifiers[@]" \
  262. '*:package:_pacman_completions_installed_packages'
  263. ;;
  264. esac
  265. }
  266. # handles --remove subcommand
  267. _pacman_action_remove() {
  268. _arguments -s : \
  269. '(--remove -R)'{-R,--remove} \
  270. "$_pacman_opts_common[@]" \
  271. "$_pacman_opts_remove[@]"
  272. }
  273. # handles --database subcommand
  274. _pacman_action_database() {
  275. _arguments -s : \
  276. '(--database -D)'{-D,--database} \
  277. "$_pacman_opts_common[@]" \
  278. "$_pacman_opts_database[@]"
  279. }
  280. # handles --files subcommand
  281. _pacman_action_files() {
  282. _arguments -s : \
  283. '(--files -F)'{-F,--files} \
  284. "$_pacman_opts_common[@]" \
  285. "$_pacman_opts_files[@]"
  286. }
  287. _pacman_action_deptest () {
  288. _arguments -s : \
  289. '(--deptest)-T' \
  290. "$_pacman_opts_common[@]" \
  291. ":packages:_pacman_all_packages"
  292. }
  293. # handles --sync subcommand
  294. _pacman_action_sync() {
  295. local context state line
  296. typeset -A opt_args
  297. if (( $+words[(r)--clean] )); then
  298. state=sync_clean
  299. elif (( $+words[(r)--groups] )); then
  300. state=sync_group
  301. elif (( $+words[(r)--search] )); then
  302. state=sync_search
  303. fi
  304. case $state in
  305. sync_clean)
  306. _arguments -s : \
  307. {\*-c,\*--clean}'[Remove old packages from cache]' \
  308. "$_pacman_opts_common[@]" \
  309. "$_pacman_opts_sync_modifiers[@]"
  310. ;;
  311. sync_group)
  312. _arguments -s : \
  313. "$_pacman_opts_common[@]" \
  314. "$_pacman_opts_sync_modifiers[@]" \
  315. '(-g --group)'{-g,--groups} \
  316. '*:package group:_pacman_completions_all_groups'
  317. ;;
  318. sync_search)
  319. _arguments -s : \
  320. "$_pacman_opts_common[@]" \
  321. "$_pacman_opts_sync_modifiers[@]" \
  322. '*:search text: '
  323. ;;
  324. *)
  325. _arguments -s : \
  326. "$_pacman_opts_common[@]" \
  327. "$_pacman_opts_sync_actions[@]" \
  328. "$_pacman_opts_sync_modifiers[@]" \
  329. '*:package:_pacman_completions_all_packages'
  330. ;;
  331. esac
  332. }
  333. # handles --upgrade subcommand
  334. _pacman_action_upgrade() {
  335. _arguments -s : \
  336. '(-U --upgrade)'{-U,--upgrade} \
  337. "$_pacman_opts_common[@]" \
  338. "$_pacman_opts_pkgfile[@]"
  339. }
  340. # handles --version subcommand
  341. _pacman_action_version() {
  342. # no further arguments
  343. return 0
  344. }
  345. # provides completions for package groups
  346. _pacman_completions_all_groups() {
  347. local -a cmd groups
  348. _pacman_get_command
  349. groups=( $(_call_program groups $cmd[@] -Sg) )
  350. typeset -U groups
  351. if [[ ${words[CURRENT-1]} == '--ignoregroup' ]]; then
  352. _sequence compadd -S ',' "$@" -a groups
  353. else
  354. compadd "$@" -a groups
  355. fi
  356. }
  357. # provides completions for packages available from repositories
  358. # these can be specified as either 'package' or 'repository/package'
  359. _pacman_completions_all_packages() {
  360. local -a seq sep cmd packages repositories packages_long
  361. if [[ ${words[CURRENT-1]} == '--ignore' ]]; then
  362. seq='_sequence'
  363. sep=(-S ',')
  364. else
  365. seq=
  366. sep=()
  367. fi
  368. if compset -P1 '*/*'; then
  369. packages=( $(_call_program packages yay -Pc ${words[CURRENT]%/*}) )
  370. typeset -U packages
  371. ${seq} _wanted repo_packages expl "repository/package" compadd ${sep[@]} ${(@)packages}
  372. else
  373. packages=( $(_call_program packages yay -Pc ) )
  374. typeset -U packages
  375. ${seq} _wanted packages expl "packages" compadd ${sep[@]} - "${(@)packages}"
  376. repositories=($(pacman-conf --repo-list))
  377. typeset -U repositories
  378. _wanted repo_packages expl "repository/package" compadd -S "/" $repositories
  379. fi
  380. }
  381. # provides completions for package groups
  382. _pacman_completions_installed_groups() {
  383. local -a cmd groups
  384. _pacman_get_command
  385. groups=(${(o)${(f)"$(_call_program groups $cmd[@] -Qg)"}% *})
  386. typeset -U groups
  387. compadd "$@" -a groups
  388. }
  389. # provides completions for installed packages
  390. _pacman_completions_installed_packages() {
  391. local -a cmd packages packages_long
  392. packages_long=(/var/lib/pacman/local/*(/))
  393. packages=( ${${packages_long#/var/lib/pacman/local/}%-*-*} )
  394. compadd "$@" -a packages
  395. }
  396. _pacman_all_packages() {
  397. _alternative : \
  398. 'localpkgs:local packages:_pacman_completions_installed_packages' \
  399. 'repopkgs:repository packages:_pacman_completions_all_packages'
  400. }
  401. # provides completions for repository names
  402. _pacman_completions_repositories() {
  403. local -a cmd repositories
  404. repositories=($(pacman-conf --repo-list))
  405. # Uniq the array
  406. typeset -U repositories
  407. compadd "$@" -a repositories
  408. }
  409. # builds command for invoking pacman in a _call_program command - extracts
  410. # relevant options already specified (config file, etc)
  411. # $cmd must be declared by calling function
  412. _pacman_get_command() {
  413. # this is mostly nicked from _perforce
  414. cmd=( "pacman" "2>/dev/null")
  415. integer i
  416. for (( i = 2; i < CURRENT - 1; i++ )); do
  417. if [[ ${words[i]} = "--config" || ${words[i]} = "--root" ]]; then
  418. cmd+=( ${words[i,i+1]} )
  419. fi
  420. done
  421. }
  422. # main dispatcher
  423. _pacman_zsh_comp() {
  424. local -a args cmds;
  425. local tmp
  426. args=( ${${${(M)words:#-*}#-}:#-*} )
  427. for tmp in $words; do
  428. cmds+=("${${_pacman_opts_commands[(r)*$tmp\[*]%%\[*}#*\)}")
  429. done
  430. case $args in #$words[2] in
  431. h*)
  432. if (( ${(c)#args} <= 1 && ${(w)#cmds} <= 1 )); then
  433. _pacman_action_help
  434. else
  435. _message "no more arguments"
  436. fi
  437. ;;
  438. *h*)
  439. _message "no more arguments"
  440. ;;
  441. D*)
  442. _pacman_action_database
  443. ;;
  444. F*)
  445. _pacman_action_files
  446. ;;
  447. Q*g*) # ipkg groups
  448. _arguments -s : \
  449. "$_pacman_opts_common[@]" \
  450. "$_pacman_opts_query_modifiers[@]" \
  451. '*:groups:_pacman_completions_installed_groups'
  452. ;;
  453. Q*o*) # file
  454. _arguments -s : \
  455. "$_pacman_opts_common[@]" \
  456. "$_pacman_opts_query_modifiers[@]" \
  457. '*:package file:_files'
  458. ;;
  459. Q*p*) # file *.pkg.tar*
  460. _arguments -s : \
  461. "$_pacman_opts_common[@]" \
  462. "$_pacman_opts_query_modifiers[@]" \
  463. '*:package file:_files -g "*.pkg.tar*~*.sig(.,@)"'
  464. ;;
  465. T*)
  466. _pacman_action_deptest
  467. ;;
  468. Q*)
  469. _pacman_action_query
  470. ;;
  471. P*)
  472. _arguments -s : \
  473. "$_pacman_opts_print_modifiers[@]"
  474. ;;
  475. R*)
  476. _pacman_action_remove
  477. ;;
  478. S*c*) # no completion
  479. _arguments -s : \
  480. '(-c --clean)'{\*-c,\*--clean}'[Remove all files from the cache]' \
  481. "$_pacman_opts_common[@]"
  482. ;;
  483. S*l*) # repos
  484. _arguments -s : \
  485. "$_pacman_opts_common[@]" \
  486. "$_pacman_opts_sync_modifiers[@]" \
  487. '*:package repo:_pacman_completions_repositories' \
  488. ;;
  489. S*g*) # pkg groups
  490. _arguments -s : \
  491. "$_pacman_opts_common[@]" \
  492. "$_pacman_opts_sync_modifiers[@]" \
  493. '*:package group:_pacman_completions_all_groups'
  494. ;;
  495. S*s*)
  496. _arguments -s : \
  497. "$_pacman_opts_common[@]" \
  498. "$_pacman_opts_sync_modifiers[@]" \
  499. '*:search text: '
  500. ;;
  501. S*)
  502. _pacman_action_sync
  503. ;;
  504. T*)
  505. _arguments -s : \
  506. '-T' \
  507. "$_pacman_opts_common[@]" \
  508. ":packages:_pacman_all_packages"
  509. ;;
  510. U*)
  511. _pacman_action_upgrade
  512. ;;
  513. V*)
  514. _pacman_action_version
  515. ;;
  516. Y*)
  517. _arguments -s : \
  518. "$_pacman_opts_yay_modifiers[@]"
  519. ;;
  520. G*)
  521. _arguments -s : \
  522. "$_pacman_opts_getpkgbuild_modifiers[@]"
  523. ;;
  524. *)
  525. case ${(M)words:#--*} in
  526. *--help*)
  527. if (( ${(w)#cmds} == 1 )); then
  528. _pacman_action_help
  529. else
  530. return 0;
  531. fi
  532. ;;
  533. *--sync*)
  534. _pacman_action_sync
  535. ;;
  536. *--query*)
  537. _pacman_action_query
  538. ;;
  539. *--remove*)
  540. _pacman_action_remove
  541. ;;
  542. *--deptest*)
  543. _pacman_action_deptest
  544. ;;
  545. *--database*)
  546. _pacman_action_database
  547. ;;
  548. *--files*)
  549. _pacman_action_files
  550. ;;
  551. *--version*)
  552. _pacman_action_version
  553. ;;
  554. *--upgrade*)
  555. _pacman_action_upgrade
  556. ;;
  557. *)
  558. _pacman_action_none
  559. ;;
  560. esac
  561. ;;
  562. esac
  563. }
  564. _pacman_comp() {
  565. case "$service" in
  566. yay)
  567. _pacman_zsh_comp "$@"
  568. ;;
  569. *)
  570. _message "Error"
  571. ;;
  572. esac
  573. }
  574. _pacman_comp "$@"