sievemgr.zsh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. #compdef sievemgr
  2. # sievemgr.zsh - completion script for ZSh
  3. #
  4. # Copyright 2024 Odin Kroeger
  5. #
  6. # This file is part of SieveManager.
  7. #
  8. # SieveManager is free software: you can redistribute it and/or
  9. # modify it under the terms of the GNU General Public License as
  10. # published by the Free Software Foundation, either version 3 of
  11. # the License, or (at your option) any later version.
  12. #
  13. # SieveManager is distributed in the hope that it will be useful,
  14. # but WITHOUT ALL WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with SieveManager. If not, see <https://www.gnu.org/licenses/>.
  20. #
  21. _sievemgr() {
  22. local context state state_descr line
  23. typeset -A opt_args
  24. _arguments -C -S -s : \
  25. '-C[Do not overwrite files.]' \
  26. '-N[Set filename of .netrc file]: :_files' \
  27. '-V[Show version.]' \
  28. '-c[Read configuration from file]: :_files' \
  29. '-d[Enable debugging mode.]' \
  30. '(-s 2 *)-e[Execute expression.]: :( )' \
  31. '-f[Overwrite and remove files without confirmation.]' \
  32. '-h[Show help.]' \
  33. '-i[Confirm removing or overwriting files.]' \
  34. '-o[Set configuration option.]: :(
  35. alias=
  36. backups=
  37. cafile=
  38. cadir=
  39. cert=
  40. confdir=
  41. confirm=
  42. getkeypass=
  43. getpass=
  44. host=
  45. key=
  46. login=
  47. ocsp=no
  48. ocsp=yes
  49. port=
  50. tls=no
  51. tls=yes
  52. saslmechs=
  53. saslprep=usernames
  54. saslprep=passwords
  55. saslprep=all
  56. saslprep=none
  57. verbosity=auth
  58. verbosity=debug
  59. verbosity=error
  60. verbosity=info
  61. verbosity=warning
  62. x509strict=no
  63. x509strict=yes
  64. )' \
  65. '-q[Be quieter.]' \
  66. '(-e 2 *)-s[Read commands from file]: :_files' \
  67. '-v[Be more verbose.]' \
  68. '1::account:->account' \
  69. '2::command:(
  70. about
  71. activate
  72. caps
  73. cat
  74. cd
  75. cert
  76. check
  77. cmp
  78. cp
  79. deactivate
  80. diff
  81. ed
  82. exit
  83. get
  84. help
  85. ls
  86. more
  87. mv
  88. put
  89. python
  90. rm
  91. sh
  92. su
  93. vi
  94. xargs
  95. )'
  96. case $state in
  97. (account)
  98. local home="${HOME-}"
  99. [ "$home" ] && eval home=~
  100. local xdg_data_home="${XDG_DATA_HOME:-"$home/.config"}"
  101. local accounts=()
  102. local config key value
  103. for config in \
  104. "/etc/sieve/config" \
  105. "/etc/sieve.cf" \
  106. "$xdg_data_home/sieve/config" \
  107. "$home/.sieve/config" \
  108. "$home/.sieve.cf"
  109. do
  110. [ -e "$config" ] || continue
  111. while read -r key value
  112. do
  113. case $key in (account|alias)
  114. [ "$value" ] && accounts+=("$value")
  115. esac
  116. done <"$config"
  117. done
  118. _describe '' accounts
  119. ;;
  120. esac
  121. } && compdef _sievemgr sievemgr