mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-21 22:53:37 +00:00
bash: complete also short options
Propose both short and long options when trying to complete a single
dash ("-").
This commit is contained in:
@@ -31,7 +31,7 @@ _guestfs_virsh_list ()
|
||||
_guestfish ()
|
||||
{
|
||||
local cur prev words cword split
|
||||
local longopts flag_ro=0 c=1 word cmds doms
|
||||
local shortopts longopts flag_ro=0 c=1 word cmds doms
|
||||
|
||||
_init_completion -s || return
|
||||
|
||||
@@ -61,6 +61,12 @@ _guestfish ()
|
||||
longopts="$(guestfish --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
|
||||
return ;;
|
||||
-*)
|
||||
# -o and --options
|
||||
shortopts="$(guestfish --short-options)"
|
||||
longopts="$(guestfish --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
|
||||
return ;;
|
||||
*)
|
||||
# Might be a guestfish command.
|
||||
cmds=$(guestfish -h| head -n -1 | tail -n +2 | awk '{print $1}')
|
||||
|
||||
@@ -31,7 +31,7 @@ _guestfs_virsh_list ()
|
||||
_guestmount ()
|
||||
{
|
||||
local cur prev words cword split
|
||||
local longopts flag_ro=0 c=1 word doms
|
||||
local shortopts longopts flag_ro=0 c=1 word doms
|
||||
|
||||
_init_completion -s || return
|
||||
|
||||
@@ -58,6 +58,12 @@ _guestmount ()
|
||||
longopts="$(guestmount --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
|
||||
return ;;
|
||||
-*)
|
||||
# -o and --options
|
||||
shortopts="$(guestmount --short-options)"
|
||||
longopts="$(guestmount --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
|
||||
return ;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen "$cur") )
|
||||
return ;;
|
||||
|
||||
@@ -31,7 +31,7 @@ _guestfs_virsh_list ()
|
||||
_guestfs_virttools ()
|
||||
{
|
||||
local cur prev words cword split
|
||||
local longopts tool="$1" flag_ro="$2" doms
|
||||
local shortopts longopts tool="$1" flag_ro="$2" doms
|
||||
|
||||
_init_completion -s || return
|
||||
|
||||
@@ -48,6 +48,12 @@ _guestfs_virttools ()
|
||||
longopts="$($tool --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
|
||||
return ;;
|
||||
-*)
|
||||
# -o and --options
|
||||
shortopts="$($tool --short-options)"
|
||||
longopts="$($tool --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
|
||||
return ;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen "$cur") )
|
||||
return ;;
|
||||
|
||||
@@ -31,7 +31,7 @@ _guestfs_virsh_list ()
|
||||
_virt_rescue ()
|
||||
{
|
||||
local cur prev words cword split
|
||||
local longopts flag_ro=0 c=1 word doms
|
||||
local shortopts longopts flag_ro=0 c=1 word doms
|
||||
|
||||
_init_completion -s || return
|
||||
|
||||
@@ -58,6 +58,12 @@ _virt_rescue ()
|
||||
longopts="$(virt-rescue --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
|
||||
return ;;
|
||||
-*)
|
||||
# -o and --options
|
||||
shortopts="$(virt-rescue --short-options)"
|
||||
longopts="$(virt-rescue --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
|
||||
return ;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen "$cur") )
|
||||
return ;;
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
_guestfs_options_only ()
|
||||
{
|
||||
local cur prev words cword split
|
||||
local longopts tool="$1"
|
||||
local shortopts longopts tool="$1"
|
||||
|
||||
_init_completion -s || return
|
||||
|
||||
@@ -29,6 +29,12 @@ _guestfs_options_only ()
|
||||
longopts="$($tool --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$longopts" -- "$cur") )
|
||||
return ;;
|
||||
-*)
|
||||
# -o and --options
|
||||
shortopts="$($tool --short-options)"
|
||||
longopts="$($tool --long-options)"
|
||||
COMPREPLY=( $(compgen -W "$shortopts $longopts" -- "$cur") )
|
||||
return ;;
|
||||
*)
|
||||
COMPREPLY=( $(compgen "$cur") )
|
||||
return ;;
|
||||
|
||||
Reference in New Issue
Block a user