zsh-workers
 help / color / mirror / code / Atom feed
181e6b0d0d91e987806f09f0445b95af5805037d blob 2259 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
 
#compdef ldap

local -a commands scopes
commands=(
  search:'search a directory'
)
scopes=(
  base:'base object only'
  one:'one level'
  sub:subtree
)

_ldap_url() {
  local nm=$compstate[nmatches]
  local -a expl protocols suf_proto suf_scope tags
  protocols=(
    ldap:'TCP in plaintext'
    ldaps:'TLS'
    ldap+tls:'TCP and use StartTLS'
    ldapi:'connect to a socket'
  )

  # [protocol://]host[:port][/basedn[?[attribute,...][?[scope][?[filter]]]]]
  if ! compset -P '*://'; then
    tags=(protocol)
    compset -S ':*' || suf_proto=( -S :// )
  fi

  if ! compset -P '*/'; then
    if compset -P '*:'; then
      tags=(port)
      compset -S '/*'
    else
      if ! compset -S '://*'; then
        tags+=(host)
        compset -S '[:/]*'
      fi
    fi
  else
    case $PREFIX in
      *\?*\?*\?*) tags=(filter);;
      *\?*\?*) tags=(scope); [[ -suffix \?* ]] || suf_scope=( -qS \? );;
      *\?*) tags=(attribute);;
      *) tags=(basedn);;
    esac
    compset -P '*\?'
    compset -S '\?*'
  fi

  _tags $tags
  while _tags; do
    _requested protocol && _describe -t protocol protocol protocols $suf_proto
    _requested host && _hosts -S ''
    _requested port expl port
    _requested basedn expl 'base DN'
    _requested attribute expl attribute
    _requested scope && _describe -t scope scope scopes $suf_scope
    _requested filter expl filter
    [[ nm -ne compstate[nmatches] ]] && return 0
  done
}

if (( CURRENT == 2 )); then
  _describe command commands
else
  shift words; (( CURRENT-- ))
  case $words[1] in
    search)
      _arguments -s -S -A '-*' \
        '-b+[specify base DN]:base DN:' \
        '-c+[specify CA file]:CA file:' \
        '-D+[specify bind DN]:bind DN:' \
        '-H+[specify URL]: :_ldap_url' \
        '-L[output in LDIF]' \
        '-l+[specify time limit or 0 for no limit]:time limit [0]:' \
        '-s+[specify scope]:scope [sub]:(($scopes))' \
        '-v[be verbose]' \
        '-W[prompt for bind secret]' \
        '-w+[specify bind secret]:bind secret:' \
        '-x[use simple authentication]' \
        '-Z[use StartTLS]' \
        '-z+[specify maximum number of results or 0 for no limit]:size limit [0]:' \
        '1: :_ldap_filters' \
        '*: :_ldap_attributes'
      ;;
  esac
fi
debug log:

solving 181e6b0d0 ...
found 181e6b0d0 in https://git.vuxu.org/mirror/zsh/

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