# lxc-* commands completion
-_lxc_names() {
+__lxc_names() {
declare -a names
case ${words[0]} in
lxc-attach | lxc-cgroup | lxc-checkpoint | lxc-console | lxc-device | lxc-freeze | lxc-stop )
done
}
-_lxc_append_name() {
+__lxc_append_name() {
mapfile -t names < <(command lxc-ls -1)
local -r shortoptnamexp="^-[0-9A-Za-mo-z]*n[0-9A-Za-mo-z]*$"
local parsed
[[ "${parsed}" == "${name}" ]] && return
done
done
- _lxc_names
+ __lxc_names
}
-_lxc_get_snapshots() {
+__lxc_get_snapshots() {
mapfile -t names < <(command lxc-ls -1)
local -r shortoptnamexp="^-[0-9A-Za-mo-z]*n[0-9A-Za-mo-z]*$"
local container
fi
}
-_lxc_common_opt() {
+__lxc_common_opt() {
# End of options.
if [[ "${words[*]}" =~ ' -- ' ]]; then
return 1
return 1
;;
--logpriority | -l )
- COMPREPLY=( $(compgen -W 'FATAL CRIT WARN ERROR NOTICE INFO DEBUG' -- "${cur}") )
+ COMPREPLY=( $( compgen -W 'FATAL CRIT WARN ERROR NOTICE INFO DEBUG' -- "${cur}" ) )
return 1
;;
--quiet | -q )
declare -A unique
for word in "${@}"; do
if [[ -z "${unique[${word}]}" ]]; then
- unique[${word}]="${word}"
+ unique["${word}"]="${word}"
else
return 0
fi
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile | -f )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_attach lxc-attach
+ __lxc_append_name
+} &&
+ complete -F _lxc_attach lxc-attach
__lxc_groups() {
declare -A groups
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--reboot | -r | --shutdown | -s | --kill | -k | --list | -L | --all | -a | --ignore-auto | -A )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_autostart lxc-autostart
+} &&
+ complete -F _lxc_autostart lxc-autostart
_lxc_cgroup() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_cgroup lxc-cgroup
+ __lxc_append_name
+} &&
+ complete -F _lxc_cgroup lxc-cgroup
_lxc_checkpoint() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_checkpoint lxc-checkpoint
+ __lxc_append_name
+} &&
+ complete -F _lxc_checkpoint lxc-checkpoint
_lxc_config() {
local cur prev words cword split
$split && return
if [[ ${cur} == -* ]]; then
- COMPREPLY=($(compgen -W '-l' -- "${cur}"))
+ COMPREPLY=( $( compgen -W '-l' -- "${cur}" ) )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
COMPREPLY=( $( compgen -W "$( command lxc-config -l )" -- "${cur}" ) )
-}
-complete -F _lxc_config lxc-config
+} &&
+ complete -F _lxc_config lxc-config
_lxc_console() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_console lxc-console
+ __lxc_append_name
+} &&
+ complete -F _lxc_console lxc-console
__lxc_backing_stores() {
COMPREPLY=( $( compgen -W 'best btrfs dir loop lvm nbd overlay overlayfs rbd zfs' -- "${cur}" ) )
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_copy lxc-copy
+ __lxc_append_name
+} &&
+ complete -F _lxc_copy lxc-copy
__lxc_templates() {
COMPREPLY=( $( compgen -W "$(command ls @LXCTEMPLATEDIR@/ | command sed -e 's|^lxc-||' )" -- "${cur}" ) )
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_create lxc-create
+} &&
+ complete -F _lxc_create lxc-create
_lxc_destroy() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_destroy lxc-destroy
+ __lxc_append_name
+} &&
+ complete -F _lxc_destroy lxc-destroy
_lxc_device() {
local cur prev words cword split
return
;;
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
add )
_available_interfaces
- COMPREPLY+=( $(compgen -f -d -X "!*/?*" -- "${cur:-/dev/}") )
+ COMPREPLY+=( $( compgen -f -d -X "!*/?*" -- "${cur:-/dev/}" ) )
return
;;
esac
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_device lxc-device
+ __lxc_append_name
+} &&
+ complete -F _lxc_device lxc-device
_lxc_execute() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile | -f )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_execute lxc-execute
+ __lxc_append_name
+} &&
+ complete -F _lxc_execute lxc-execute
_lxc_freeze() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile | -f )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_freeze lxc-freeze
+ __lxc_append_name
+} &&
+ complete -F _lxc_freeze lxc-freeze
_lxc_info() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_info lxc-info
+ __lxc_append_name
+} &&
+ complete -F _lxc_info lxc-info
_lxc_ls() {
local cur prev words cword split
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--line | -1 | --fancy | -f | --active | --frozen | --running | --stopped | --defined )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_ls lxc-ls
+} &&
+ complete -F _lxc_ls lxc-ls
_lxc_monitor() {
local cur prev words cword split
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--quit | -Q )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_monitor lxc-monitor
+ __lxc_append_name
+} &&
+ complete -F _lxc_monitor lxc-monitor
_lxc_snapshot() {
local cur prev words cword split
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
return
;;
--destroy | -d )
- COMPREPLY=( $( compgen -W 'ALL $( _lxc_get_snapshots )' -- "${cur}" ) )
+ COMPREPLY=( $( compgen -W 'ALL $( __lxc_get_snapshots )' -- "${cur}" ) )
return
;;
--list | -L | --showcomments | -C )
# Only flags.
;;
--restore | -r )
- COMPREPLY=( $( compgen -W '$( _lxc_get_snapshots )' -- "${cur}" ) )
+ COMPREPLY=( $( compgen -W '$( __lxc_get_snapshots )' -- "${cur}" ) )
return
;;
--newname | -N )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_snapshot lxc-snapshot
+ __lxc_append_name
+} &&
+ complete -F _lxc_snapshot lxc-snapshot
_lxc_start() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--daemon | -d | --foreground | -F | --close-all-fds | -C )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_start lxc-start
+ __lxc_append_name
+} &&
+ complete -F _lxc_start lxc-start
_lxc_stop() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_stop lxc-stop
+ __lxc_append_name
+} &&
+ complete -F _lxc_stop lxc-stop
_lxc_top() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--batch | -b | --reverse | -r )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_top lxc-top
+} &&
+ complete -F _lxc_top lxc-top
_lxc_unfreeze() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_unfreeze lxc-unfreeze
+ __lxc_append_name
+} &&
+ complete -F _lxc_unfreeze lxc-unfreeze
_lxc_unshare() {
local cur prev words cword split
COMPREPLY=()
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--namespaces | -s )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_unshare lxc-unshare
+} &&
+ complete -F _lxc_unshare lxc-unshare
_lxc_update_config() {
local cur prev words cword split
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-
-}
-complete -F _lxc_update_config lxc-update-config
+} &&
+ complete -F _lxc_update_config lxc-update-config
_lxc_usernsexec() {
local cur prev words cword split
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
-}
-complete -F _lxc_usernsexec lxc-usernsexec
+} &&
+ complete -F _lxc_usernsexec lxc-usernsexec
_lxc_wait() {
local cur prev words cword split
_init_completion -s -n : || return
- _lxc_common_opt || return
+ __lxc_common_opt || return
case ${prev} in
--name | -n )
- _lxc_names
+ __lxc_names
return
;;
--rcfile )
[[ ${COMPREPLY-} == *= ]] && compopt -o nospace
return
fi
- _lxc_append_name
-}
-complete -F _lxc_wait lxc-wait
+ __lxc_append_name
+} &&
+ complete -F _lxc_wait lxc-wait
# ex: filetype=sh