zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH 1/4] _postfix: Use mailq to obtain queue id's.
@ 2016-08-27 18:44 Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 2/4] _postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper' Daniel Shahaf
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Shahaf @ 2016-08-27 18:44 UTC (permalink / raw)
  To: zsh-workers

'mailq' is usually in */bin (as opposed to */sbin) and so is more likely
to be in $PATH.
---
 Completion/Unix/Command/_postfix | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix
index 0ced6c2..6811569 100644
--- a/Completion/Unix/Command/_postfix
+++ b/Completion/Unix/Command/_postfix
@@ -1,7 +1,7 @@
 #compdef postsuper
 
 _postfix_queue_id() {
-compadd ${${(M)${(f)"$(postqueue -p)"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
+  compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
 }
 
 case $service in


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/4] _postfix: Complete 'postqueue'.  Also minor tweaks to 'postsuper'.
  2016-08-27 18:44 [PATCH 1/4] _postfix: Use mailq to obtain queue id's Daniel Shahaf
@ 2016-08-27 18:44 ` Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 3/4] _postfix: Complete 'postconf' Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 4/4] _postfix: Support $enable_long_queue_ids Daniel Shahaf
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2016-08-27 18:44 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_postfix | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix
index 6811569..2e6a0a0 100644
--- a/Completion/Unix/Command/_postfix
+++ b/Completion/Unix/Command/_postfix
@@ -1,4 +1,4 @@
-#compdef postsuper
+#compdef postqueue postsuper
 
 _postfix_queue_id() {
   compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
@@ -6,15 +6,25 @@ _postfix_queue_id() {
 
 case $service in
 	(postsuper)
-	_arguments -C \
+	_arguments -C -s : \
 	'-p[purge old tempfiles]' \
 	'-s[structure check and repair]' \
-	'-v[verbose]' \
+	'*-v[verbose]' \
 	'-c[configdir]:config dir:_files -/' \
 	'-d[delete]:queue id:_postfix_queue_id' \
 	'-h[hold]:queue id:_postfix_queue_id' \
 	'-H[release]:queue id:_postfix_queue_id' \
-	'-r[requeue]:queue id:_postfix_queue_id' \
+	'*-r[requeue]:queue id, or "ALL":_postfix_queue_id' \
 	'1:queue:(hold incoming active deferred)'
 	;;
+        (postqueue)
+        _arguments -C -s : \
+          '*-v[enable verbose logging]' \
+          '-c[configdir]:config dir:_files -/' \
+          '(-f -i -j -p -s)-f[flush the queue]' \
+          '(-f -i -j -p -s)-i[immediately deliver one message]:queue id:_postfix_queue_id' \
+          '(-f -i -j -p -s)-j[print the queue in json]' \
+          '(-f -i -j -p -s)-p[print the queue in traditional format]' \
+          '(-f -i -j -p -s)-s[immediately deliver messages to specified site]:site:_hosts' 
+        ;;
 esac


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/4] _postfix: Complete 'postconf'.
  2016-08-27 18:44 [PATCH 1/4] _postfix: Use mailq to obtain queue id's Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 2/4] _postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper' Daniel Shahaf
@ 2016-08-27 18:44 ` Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 4/4] _postfix: Support $enable_long_queue_ids Daniel Shahaf
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2016-08-27 18:44 UTC (permalink / raw)
  To: zsh-workers

---
 Completion/Unix/Command/_postfix | 107 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix
index 2e6a0a0..8880dbf 100644
--- a/Completion/Unix/Command/_postfix
+++ b/Completion/Unix/Command/_postfix
@@ -1,9 +1,36 @@
-#compdef postqueue postsuper
+#compdef postconf postqueue postsuper
+
+# Last updated from postfix 3.1.0.
+
+local context state state_descr line
+typeset -A opt_args
+integer NORMARG
 
 _postfix_queue_id() {
   compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
 }
 
+_postfix_main_cf_parameter() {
+  local expl
+  # Note for the future: if $mail_version >= 3.1, we can pass -H instead of
+  # stripping the = signs by hand.
+  _wanted parameters expl 'main.cf parameter' compadd "$@" -- ${${(f)"$(_call_program postconf-defaults "${(q)words[1]} -d")"}%% =*}
+}
+
+_postfix_main_cf_parameter_and_value() {
+  # Note: be careful not to accidentally run 'postconf foo=bar' here.
+  #
+  # The '-P 1' syntax chooses the shortest match.  If the '1' were removed,
+  # completing «postconf foo=bar=<TAB>» would change main.cf.  So, don't remove
+  # it.
+  if compset -P 1 '*='; then
+    local value="`_call_program postconf-get-value-at-dir "${(q)words[1]} ${opt_args[-c]+"-c ${(q)opt_args[-c]}"} -h -- ${(q)IPREFIX%=}"`"
+    [[ -n $value ]] && compadd "$@" -- $value
+  else
+    _postfix_main_cf_parameter -S=
+  fi
+}
+
 case $service in
 	(postsuper)
 	_arguments -C -s : \
@@ -27,4 +54,82 @@ case $service in
           '(-f -i -j -p -s)-p[print the queue in traditional format]' \
           '(-f -i -j -p -s)-s[immediately deliver messages to specified site]:site:_hosts' 
         ;;
+        (postconf)
+          local -a file_ops=(-b -t -a -A -l -m -T)
+          local -a modes=(-F -M -P $file_ops -p)
+          local -a only_for_p=(-C -d -h -n)
+          local -a only_for_asterisk_dot_cf=(-e -f -o -x)
+          local -a args=(
+              # global
+              '-c[configdir]:config dir:_files -/' \
+              '*-v[enable verbose logging]'
+
+              # mode selection
+              "($modes $only_for_p                              -X -#)"'-F[operate on master.cf entry fields]'
+              "($modes $only_for_p                           -H      )"'-M[operate on master.cf services entries]'
+              "($modes $only_for_p                                 -#)"'-P[operate on master.cf parameter settings]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-b[display DSN text, expanded]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-t[display DSN text, unexpanded]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-a[list available SASL server plug-ins]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-A[list available SASL client plug-ins]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-l[list supported mailbox locking methods]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-m[list supported lookup table types]'
+              "($modes                                               )"'-p[(default) print main.cf settings]'
+              "($modes $only_for_p $only_for_asterisk_dot_cf -H -X -#)"'-T[print TLS information]:mode:((
+                           compile-version\:"OpenSSL compile-time version"
+                           run-version\:"OpenSSL run-time version"
+                           public-key-algorithms\:"supported public-key algorithms"
+                           ))'
+
+              # other options; comments indicate modes:
+              # -p only
+              '-C[display parameters from the specified class]:parameter class:(builtin service user all)'
+              '-d[print default values]'
+              '-h[print value only]'
+              '-n[show parameters changed in main.cf]'
+
+              # all except $file_ops:
+              '-e[change parameter values]'
+              '-f[fold long output lines]'
+              '-o[set parameter value for this operation]: :_postfix_main_cf_parameter_and_value'
+              '-x[expand '\''$name'\'' in parameter values]'
+
+              # -p -F -P only
+              '-H[show parameter name only]'
+              # -p -M -P only
+              '-X[remove parameters from main.cf/master.cf]'
+              # -p -M only
+              '-#[comment out parameters in main.cf/master.cf]'
+
+              # $state
+              '*: :->positional'
+          )
+          _arguments -C -s -S -n : "$args[@]"
+
+          case $state in
+            (positional)
+              # Simulate the default
+              if [[ -z $opt_args[(i)${(j.|.)modes}] ]]; then
+                opt_args[-p]=""
+              fi
+              if [[ -n $opt_args[(i)(-b|-t)] ]]; then
+                local expl
+                if (( CURRENT == NORMARG )); then
+                  _wanted files expl 'template file, or "" for default' _files
+                else
+                  _nothing
+                fi
+              elif [[ -n $opt_args[(i)${(j.|.)file_ops}] ]]; then
+                _nothing
+              elif (( $+opt_args[-p] )); then
+                if (( $+opt_args[-e] )); then
+                  _postfix_main_cf_parameter_and_value
+                else
+                  _postfix_main_cf_parameter
+                fi
+              else # one of the master.cf modes: -M -F -P
+                _message "arguments for $opt_args[(i)${(j.|.)modes}] mode"
+              fi
+          esac
+        ;;
 esac


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/4] _postfix: Support $enable_long_queue_ids.
  2016-08-27 18:44 [PATCH 1/4] _postfix: Use mailq to obtain queue id's Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 2/4] _postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper' Daniel Shahaf
  2016-08-27 18:44 ` [PATCH 3/4] _postfix: Complete 'postconf' Daniel Shahaf
@ 2016-08-27 18:44 ` Daniel Shahaf
  2 siblings, 0 replies; 4+ messages in thread
From: Daniel Shahaf @ 2016-08-27 18:44 UTC (permalink / raw)
  To: zsh-workers

Note that this not only adds a second compadd invocation but also adds a space
to the first compadd invocation, to prevent the start of a new-style queue id
from matching as an old-style queue id.
---
 Completion/Unix/Command/_postfix | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Completion/Unix/Command/_postfix b/Completion/Unix/Command/_postfix
index 8880dbf..e610a1d 100644
--- a/Completion/Unix/Command/_postfix
+++ b/Completion/Unix/Command/_postfix
@@ -7,7 +7,13 @@ typeset -A opt_args
 integer NORMARG
 
 _postfix_queue_id() {
-  compadd "$@" -- ${${(M)${(f)"$(_call_program mailq 'mailq')"}:#(#s)([0-9A-F]##)*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
+  local -a lines=( ${(f)"$(_call_program mailq 'mailq')"} )
+
+  # $enable_long_queue_ids = no
+  compadd "$@" -- ${${(M)lines:#(#s)([0-9A-F]## )*}/(#s)(#b)([0-9A-F]##)*/$match[1]}
+
+  # $enable_long_queue_ids = yes
+  compadd "$@" -- ${${(M)lines:#(#s)[0-9bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ](#c10)z*}%% *}
 }
 
 _postfix_main_cf_parameter() {


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-08-27 18:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-27 18:44 [PATCH 1/4] _postfix: Use mailq to obtain queue id's Daniel Shahaf
2016-08-27 18:44 ` [PATCH 2/4] _postfix: Complete 'postqueue'. Also minor tweaks to 'postsuper' Daniel Shahaf
2016-08-27 18:44 ` [PATCH 3/4] _postfix: Complete 'postconf' Daniel Shahaf
2016-08-27 18:44 ` [PATCH 4/4] _postfix: Support $enable_long_queue_ids Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).