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
| | #compdef softwareupdate
_softwareupdate_update_name() {
local name line
if [[ ! -v _softwareupdate_updates ]]; then
_softwareupdate_updates=()
for line in ${(f)"$(_call_program pkgs softwareupdate --list)"}; do
if [[ $line == ' '* ]]; then
name="${line# ? }"
elif [[ -n "$name" ]]; then
_softwareupdate_updates+=("$name:${line# }")
name=""
fi
done
fi
if (( ${#_softwareupdate_updates} > 0 )); then
_describe -t pkgs "update name" _softwareupdate_updates && return 0
fi
return 1
}
_softwareupdate() {
local context state line expl
typeset -A opt_args
_arguments -R \
'(-h --help -l --list)-q[quiet mode]' \
{-l,--list}'[list all available updates]:*:' \
{-d,--download}'[download only]:*:' \
{-i,--install}'[install (requires root)]:*: :->install' \
'--list-full-installers[list the available macOS installers]' \
'--fetch-full-installer[install the latest recommended macOS installer]:*: :->fetch-installer' \
'--install-rosetta[install rosetta]' \
'--background[trigger a background scan and update operation]' \
'--schedule[scheduler preferences (per-user)]:automatic checking:(on off)' \
'--dump-state[log the internal state of the SU daemon to /var/log/install.log]' \
'--evaluate-products[evaluate a list of product keys specified by the --products option]' \
'--history[show the install history]' \
'--no-scan[do not scan when listing or installing updates]' \
'--product-types[limit a scan to a particular product type only]:product_type' \
'--products[a comma separated list of product keys to operate on]:product_keys' \
'--force[force an operation to complete]' \
'--agree-to-license[agree to the software license agreement without user interaction]' \
'--verbose[enable verbose output]' \
{-h,--help}'[print command usage]:*:' && return 0
case "$state" in
install)
_arguments \
'(-a --all)'{-a,--all}'[all available active updates]' \
'(-r --recommended)'{-r,--recommended}'[all updates that are recommended for your system]' \
'--os-only[only macOS updates]' \
'--safari-only[only safari updates]' \
'(-R --restart)'{-R,--restart}'[automatically restart if required to complete installation]' \
'--stdinpass[password to authenticate as an owner]' \
'--user[local username to authenticate as an owner]' \
'*:update name:_softwareupdate_update_name' && return 0
;;
fetch-installer)
_arguments \
'--full-installer-version[specify the version macOS to install]:version' \
;;
esac
return 1
}
_softwareupdate "$@"
|