shell-completion: replace "gdb" verb with "debug" for coredumpctl

Also offer --debugger option.  Both to reflect changes in v239.
This commit is contained in:
Jan Pokorný 2018-08-16 18:23:16 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 1e190dfd5b
commit 53956faf74
2 changed files with 9 additions and 4 deletions

View File

@ -39,11 +39,11 @@ _coredumpctl() {
local i verb comps local i verb comps
local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]} local cur=${COMP_WORDS[COMP_CWORD]} prev=${COMP_WORDS[COMP_CWORD-1]}
local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1 local OPTS='-h --help --version --no-pager --no-legend -o --output -F --field -1
-r --reverse -S --since -U --until -D --directory -q --quiet' -r --reverse -S --since -U --until -D --directory -q --quiet --debugger'
local -A VERBS=( local -A VERBS=(
[LIST]='list info' [LIST]='list info'
[DUMP]='dump gdb' [DUMP]='dump debug'
) )
if __contains_word "$prev" '--output -o'; then if __contains_word "$prev" '--output -o'; then
@ -52,12 +52,16 @@ _coredumpctl() {
elif __contains_word "$prev" '-D --directory'; then elif __contains_word "$prev" '-D --directory'; then
comps=$( compgen -A directory -- "$cur" ) comps=$( compgen -A directory -- "$cur" )
compopt -o filenames compopt -o filenames
elif __contains_word "$prev" '--debugger'; then
comps=$( compgen -A command -- "$cur" )
compopt -o filenames
elif __contains_word "$prev" '--field -F'; then elif __contains_word "$prev" '--field -F'; then
comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" ) comps=$( compgen -W '${__journal_fields[*]}' -- "$cur" )
elif [[ $cur = -* ]]; then elif [[ $cur = -* ]]; then
comps=${OPTS} comps=${OPTS}
elif __contains_word "$prev" ${VERBS[*]} && elif __contains_word "$prev" ${VERBS[*]} &&
! __contains_word ${COMP_WORDS[COMP_CWORD-2]} '--output -o -D --directory -F --field'; then ! __contains_word ${COMP_WORDS[COMP_CWORD-2]} \
'--output -o -D --directory -F --field --debugger'; then
compopt -o nospace compopt -o nospace
COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") ) COMPREPLY=( $(compgen -W '${__journal_fields[*]}' -S= -- "$cur") )
return 0 return 0

View File

@ -7,7 +7,7 @@ _coredumpctl_command(){
'list:List available coredumps' 'list:List available coredumps'
'info:Show detailed information about one or more coredumps' 'info:Show detailed information about one or more coredumps'
'dump:Print coredump to stdout' 'dump:Print coredump to stdout'
'gdb:Start gdb on a coredump' 'debug:Start debugger (gdb) on a coredump'
) )
if (( CURRENT == 1 )); then if (( CURRENT == 1 )); then
_describe -t commands 'coredumpctl command' _coredumpctl_cmds _describe -t commands 'coredumpctl command' _coredumpctl_cmds
@ -39,4 +39,5 @@ _arguments \
'--no-legend[Do not print the column headers]' \ '--no-legend[Do not print the column headers]' \
{-h,--help}'[Show this help]' \ {-h,--help}'[Show this help]' \
'--version[Show package version]' \ '--version[Show package version]' \
'--debugger=[Use the given debugger]' \
'*::coredumpctl commands:_coredumpctl_command' '*::coredumpctl commands:_coredumpctl_command'