zsh-workers
 help / color / mirror / code / Atom feed
22127fed7fd0d1ad77f55877a64f58a8f28aae9f blob 2491 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
 
#compdef hostname

local ret=1
local -a context line state state_descr args aopts tmp
local -A opt_args

if _pick_variant net-tools=--yp unix --help; then
  args=(
    '(: * -)'{-h,--help}'[display help information]'
    '(: * -)'{-V,--version}'[display version information]'
    + '(g)' # Get
    '(: gs s)'{-A,--all-fqdns}'[display FQDNs resolved from network interface addresses]'
    '(: gs s)'{-d,--domain}'[display DNS domain only]'
    '(: gs s)'{-f,--fqdn,--long}'[display host name with DNS domain (FQDN)]'
    '(: gs s)'{-i,--ip-address}'[display IP addresses for host (via DNS resolution)]'
    '(: gs s)'{-I,--all-ip-addresses}'[display IP addresses for host (via network interfaces)]'
    '(: gs s)'{-s,--short}'[display short host name only]'
    + '(gs)' # Get/set
    '(g)'{-y,--yp,--nis}'[display NIS domain only]'
    + s # Set
    '(-b --boot g)'{-b,--boot}'[always set a host name]'
    '(: -F --file g)'{-F+,--file=}'[read host name to set from specified file]: :_files'
    + o
    '(-F --file g)1: :->host-or-domain'
  )
else
  aopts=( -A '-*' )
  args=(
    '(-4 -6 -d -f -i -r -s)1: :_guard "^-*" "host name"'
    '(: -4 -6 -d -f)-s[display short host name only]'
  )

  case $OSTYPE in
    darwin*|freebsd*)
      args+=(
        '(: -d -s)-f[display host name with DNS domain (FQDN)]'
      )
      ;| # MATCH AGAIN
    freebsd*)
      args+=(
        '(: -f -s)-d[display DNS domain only]'
      )
      ;;
    dragonfly*)
      args+=(
        '(: -6 -r)-4[use first IPv4 address on interface (with -i)]'
        '(: -4 -r)-6[use first IPv6 address on interface (with -i)]'
        '(: -r)-i+[retrieve host name via specified interface]: :_net_interfaces'
        '(: -4 -6 -i)-r+[retrieve host name via specified IP address]: :->ip-address'
      )
      ;;
  esac
fi

_arguments -s -S $aopts : $args && ret=0

case $state in
  host-or-domain)
    [[ -prefix -* ]] ||
    if [[ -n ${opt_args[(i)*-(-y|--yp|--nis)]} ]]; then
      _message -e nis-domains 'NIS domain' && ret=0
    else
      _message -e host-names 'host name' && ret=0
    fi
    ;;
  ip-address)
    # @todo Should we have a proper type function for local IPs?
    tmp=( ${(f)"$( _call_program ip-addresses ifconfig -a )"} )
    tmp=( ${(@M)tmp##(|[[:space:]]##)inet(|6)(|:)[[:space:]]*} )
    tmp=( ${(@)tmp#*inet(|6)(|:)[[:space:]]##} )
    tmp=( ${(@)tmp%%[^0-9A-Fa-f:.]*} )
    tmp=( ${(@u)${(@)tmp//:/\\:}} )
    _describe -t ip-addresses 'IP address' tmp && ret=0
    ;;
esac

return ret
debug log:

solving 22127fed7 ...
found 22127fed7 in https://inbox.vuxu.org/zsh-workers/6B9F94D1-6E43-4970-8571-C935B6167EB0@dana.is/

applying [1/1] https://inbox.vuxu.org/zsh-workers/6B9F94D1-6E43-4970-8571-C935B6167EB0@dana.is/
diff --git a/Completion/Unix/Command/_hostname b/Completion/Unix/Command/_hostname
new file mode 100644
index 000000000..22127fed7

Checking patch Completion/Unix/Command/_hostname...
Applied patch Completion/Unix/Command/_hostname cleanly.

index at:
100644 22127fed7fd0d1ad77f55877a64f58a8f28aae9f	Completion/Unix/Command/_hostname

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