mirror of
https://github.com/systemd/systemd.git
synced 2025-01-10 05:18:17 +03:00
20927c0eec
* fix error * remove options that are no longer supported * add missing options * stop completion if an option `--help` or `--version` is supplied [[[ zjs: a note for the reader: zshcompsys(1) in the section about optspecs in _arguments says: > Each of the forms above may be preceded by a list in parentheses of option names and argument num‐ > bers. If the given option is on the command line, the options and arguments indicated in parentheses > will not be offered. For example, ‘(-two -three 1)-one:...' completes the option ‘-one'; if this ap‐ > pears on the command line, the options -two and -three and the first ordinary argument will not be > completed after it. ‘(-foo):...' specifies an ordinary argument completion; -foo will not be com‐ > pleted if that argument is already present. > > Other items may appear in the list of excluded options to indicate various other items that should > not be applied when the current specification is matched: a single star (\*) for the rest arguments > (i.e. a specification of the form ‘\*:...'); a colon (:) for all normal (non-option-) arguments; and a > hyphen (-) for all options. For example, if ‘(\*)' appears before an option and the option appears on > the command line, the list of remaining arguments (those shown in the above table beginning with > ‘\*:') will not be completed. The intended effect of the change is to remove irrelevant completion matches from the completion. tl;dr: (- : ) prevents further completion ]]]
29 lines
868 B
Plaintext
29 lines
868 B
Plaintext
#compdef oomctl
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
(( $+functions[_oomctl_commands] )) || _oomctl_commands()
|
|
{
|
|
local -a _oomctl_cmds
|
|
_oomctl_cmds=(
|
|
"dump:Show the current state of cgroups and system contexts"
|
|
"help:Prints a short help text and exits."
|
|
)
|
|
if (( CURRENT == 1 )); then
|
|
_describe -t commands 'oomctl command' _oomctl_cmds
|
|
else
|
|
local curcontext="$curcontext"
|
|
cmd="${${_oomctl_cmds[(r)$words[1]:*]%%:*}}"
|
|
if (( $+functions[_oomctl_$cmd] )); then
|
|
_oomctl_$cmd
|
|
else
|
|
_message "no more options"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
_arguments \
|
|
'(- *)'{-h,--help}'[Prints a short help text and exits.]' \
|
|
'(- *)--version[Prints a short version string and exits.]' \
|
|
'--no-pager[Do not pipe output into a pager]' \
|
|
'*::oomctl command:_oomctl_commands'
|