chiark / gitweb /
833c7e2bb1b96a7e262eacdb01607be1e99b11bb
[elogind.git] / shell-completion / zsh / _coredumpctl
1 #compdef coredumpctl
2
3 _coredumpctl_command(){
4     local -a _coredumpctl_cmds
5     _coredumpctl_cmds=(
6             'list:List available coredumps'
7             'info:Show detailed information about one or more coredumps'
8             'dump:Print coredump to stdout'
9             'gdb:Start gdb on a coredump'
10     )
11     if (( CURRENT == 1 )); then
12         _describe -t commands 'coredumpctl command' _coredumpctl_cmds
13     else
14         local curcontext="$curcontext"
15         local -a _dumps
16         cmd="${${_coredumpctl_cmds[(r)$words[1]:*]%%:*}}"
17         if (( $#cmd  )); then
18             # user can set zstyle ':completion:*:*:coredumpctl:*' sort no for coredumps to be ordered by date, otherwise they get ordered by pid
19             _dumps=( "${(foa)$(coredumpctl list | awk 'BEGIN{OFS=":"} /^\s/ {sub(/[[ \t]+/, ""); print $5,$0}' 2>/dev/null)}" )
20             if [[ -n "$_dumps" ]]; then
21                 _describe -t pids 'coredumps' _dumps
22             else
23                 _message "no coredumps"
24             fi
25         else
26             _message "no more options"
27         fi
28     fi
29 }
30
31 _arguments \
32     {-o+,--output=}'[Write output to FILE]:output file:_files' \
33     {-F+,--field=}'[Show field in list output]:field' \
34     '-1[Show information about most recent entry only]' \
35     '--no-pager[Do not pipe output into a pager]' \
36     '--no-legend[Do not print the column headers]' \
37     {-h,--help}'[Show this help]' \
38     '--version[Show package version]' \
39     '*::coredumpctl commands:_coredumpctl_command'