zsh-workers
 help / color / mirror / code / Atom feed
42cf485dc434b09e67c404cb9594706b21d9b2e0 blob 1709 bytes (raw)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
 
#autoload

# Complete syslog-style priorities/facilities/levels
#
# Note: 'Priority' according to syslog(3) refers to a severity level optionally
# ORed with a facility. We use it here in a somewhat similar manner, as this
# seems to cover the most ground, though we also support completing facilities
# alone.
#
# By default, a case-insensitive facility.level pair is completed.
#
# Some tools that accept symbolic facility/level names also accept numbers
# corresponding to their associated values defined in syslog.h. Since these
# numbers vary across systems, we don't attempt to complete them.
#
# Options:
#   -y  Complete only facilities
#   -Y  Complete only severity levels
#   -z  Complete only lower-case names
#   -Z  Complete only upper-case names

local -a expl facilities levels ca_opts
local -A opts

# Facilities vary across systems too, but these seem common enough
facilities=(
  kern
  user
  mail
  daemon
  auth
  syslog
  lpr
  news
  uucp
  cron
  authpriv
  ftp
  ntp
  security
  local{0..7}
)
levels=(
  emerg   # 'panic' is deprecated
  alert
  crit
  err     # 'error' is deprecated
  warning # 'warn' is deprecated
  notice
  info
  debug
)

zparseopts -A opts -D -E -- y Y z Z

if (( $+opts[-Z] )); then
  facilities=( ${(@U)facilities} )
  levels=( ${(@U)levels} )
elif (( ! $+opts[-z] )); then
  ca_opts+=( -M 'm:{a-zA-Z}={A-Za-z}' )
fi

if (( $+opts[-Y] )) || { (( ! $+opts[-y] )) && compset -P '[^.]##.' }; then
  _wanted levels expl 'log severity level' \
      compadd -a "$@" "${(@)ca_opts}" - levels
else
  (( ! $+opts[-y] )) && ! compset -S '.[^.]##' && ca_opts+=( -qS. )
  _wanted facilities expl 'log facility' \
      compadd -a "$@" "${(@)ca_opts}" - facilities
fi
debug log:

solving 42cf485dc ...
found 42cf485dc in https://inbox.vuxu.org/zsh-workers/E00A62F9-627E-4C0C-A3FD-3A0C1F00D666@dana.is/

applying [1/1] https://inbox.vuxu.org/zsh-workers/E00A62F9-627E-4C0C-A3FD-3A0C1F00D666@dana.is/
diff --git a/Completion/Unix/Type/_log_priorities b/Completion/Unix/Type/_log_priorities
new file mode 100644
index 000000000..42cf485dc

Checking patch Completion/Unix/Type/_log_priorities...
Applied patch Completion/Unix/Type/_log_priorities cleanly.

index at:
100644 42cf485dc434b09e67c404cb9594706b21d9b2e0	Completion/Unix/Type/_log_priorities

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).