mirror of
https://github.com/systemd/systemd.git
synced 2025-01-05 13:18:06 +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 ]]]
48 lines
2.0 KiB
Plaintext
48 lines
2.0 KiB
Plaintext
#compdef coredumpctl
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
(( $+functions[_coredumpctl_commands] )) ||
|
|
_coredumpctl_commands(){
|
|
local -a _coredumpctl_cmds
|
|
_coredumpctl_cmds=(
|
|
'list:List available coredumps'
|
|
'info:Show detailed information about one or more coredumps'
|
|
'dump:Print coredump to stdout'
|
|
'debug:Start debugger (gdb) on a coredump'
|
|
)
|
|
if (( CURRENT == 1 )); then
|
|
_describe -t commands 'coredumpctl command' _coredumpctl_cmds
|
|
else
|
|
local curcontext="$curcontext"
|
|
local -a _dumps
|
|
cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
|
|
if (( $#cmd )); then
|
|
_dumps=( "${(f)$(coredumpctl list -q --no-legend | awk 'BEGIN{OFS=":"} {sub(/[[ \t]+/, ""); print $4,$0}' 2>/dev/null)}" )
|
|
if [[ -n "$_dumps" ]]; then
|
|
_describe -V -t pids 'coredumps' _dumps
|
|
else
|
|
_message "no coredumps"
|
|
fi
|
|
else
|
|
_message "no more options"
|
|
fi
|
|
fi
|
|
}
|
|
|
|
_arguments \
|
|
'(-o --output)'{-o+,--output=}'[Write output to FILE]:output file:_files' \
|
|
'(-F --field)'{-F+,--field=}'[Show field in list output]:field' \
|
|
'-1[Show information about most recent entry only]' \
|
|
'(-S --since)'{-S,--since}'[Print entries since the specified date]' \
|
|
'(-U --until)'{-U,--until}'[Print entries until the specified date]' \
|
|
'(-r --reverse)'{-r,--reverse}'[Show the newest entries first]' \
|
|
'--no-pager[Do not pipe output into a pager]' \
|
|
'--no-legend[Do not print the column headers]' \
|
|
'(- *)'{-h,--help}'[Show this help]' \
|
|
'(- *)--version[Show package version]' \
|
|
'--debugger=[Use the given debugger]:debugger: _command_names -e' \
|
|
'(-D --directory)'{-D,--directory=}'[Use the journal files in the specified dir]:directory: _directories' \
|
|
'(-q --quiet)'{-q,--quiet}'[Do not show info messages and privilege warning]' \
|
|
'--all[Look at all journal files instead of local ones]' \
|
|
'*::coredumpctl commands:_coredumpctl_commands'
|