#compdef vmexec

autoload -U is-at-least

_vmexec() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" : \
'--log-level=[Log messages above specified level (error, warn, info, debug, trace)]:LOG_LEVEL:_default' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_vmexec_commands" \
"*::: :->vmexec" \
&& ret=0
    case $state in
    (vmexec)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:vmexec-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
'*-e+[Set environment variables for the process inside the virtual machine]:ENV:_default' \
'*--env=[Set environment variables for the process inside the virtual machine]:ENV:_default' \
'*-v+[Bind mount a volume into the virtual machine]:VOLUMES:_default' \
'*--volume=[Bind mount a volume into the virtual machine]:VOLUMES:_default' \
'*--pmem=[Mount a virtio-pmem device file into the virtual machine]:PMEMS:_default' \
'*-p+[Publish a port on the virtual machine to the host]:PUBLISHED_PORTS:_default' \
'*--publish=[Publish a port on the virtual machine to the host]:PUBLISHED_PORTS:_default' \
'-s+[SSH connection timeout]:SSH_TIMEOUT:_default' \
'--ssh-timeout=[SSH connection timeout]:SSH_TIMEOUT:_default' \
'-i+[Make STDIN available to the virtual machine'\''s process]:INTERACTIVE:(always never auto)' \
'--interactive=[Make STDIN available to the virtual machine'\''s process]:INTERACTIVE:(always never auto)' \
'-t+[Allocate a pseudo-TTY for the virtual machine]:TTY:(always never auto)' \
'--tty=[Allocate a pseudo-TTY for the virtual machine]:TTY:(always never auto)' \
'--pull=[When to pull a new image]:PULL:(missing never newer)' \
'--show-vm-window[Show a window with the virtual machine running in it]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':image_source -- Either an operating system (e.g. archlinux) or a path to an image:_default' \
'*::args -- Arguments to run in the virtual machine:_default' \
&& ret=0
;;
(ksm)
_arguments "${_arguments_options[@]}" : \
'-e[Persistently enable KSM by writing settings to /etc/tmpfiles.d/ksm.conf]' \
'--enable[Persistently enable KSM by writing settings to /etc/tmpfiles.d/ksm.conf]' \
'-d[Persistently disable KSM by deleting /etc/tmpfiles.d/ksm.conf]' \
'--disable[Persistently disable KSM by deleting /etc/tmpfiles.d/ksm.conf]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':shell:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(manpage)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':out_dir:_files' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_vmexec__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:vmexec-help-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(ksm)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(manpage)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_vmexec_commands] )) ||
_vmexec_commands() {
    local commands; commands=(
'run:Run a command in a new virtual machine' \
'ksm:Check and change KSM status' \
'completions:Generate completion file for a shell' \
'manpage:Print man page' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'vmexec commands' commands "$@"
}
(( $+functions[_vmexec__completions_commands] )) ||
_vmexec__completions_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec completions commands' commands "$@"
}
(( $+functions[_vmexec__help_commands] )) ||
_vmexec__help_commands() {
    local commands; commands=(
'run:Run a command in a new virtual machine' \
'ksm:Check and change KSM status' \
'completions:Generate completion file for a shell' \
'manpage:Print man page' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'vmexec help commands' commands "$@"
}
(( $+functions[_vmexec__help__completions_commands] )) ||
_vmexec__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec help completions commands' commands "$@"
}
(( $+functions[_vmexec__help__help_commands] )) ||
_vmexec__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec help help commands' commands "$@"
}
(( $+functions[_vmexec__help__ksm_commands] )) ||
_vmexec__help__ksm_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec help ksm commands' commands "$@"
}
(( $+functions[_vmexec__help__manpage_commands] )) ||
_vmexec__help__manpage_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec help manpage commands' commands "$@"
}
(( $+functions[_vmexec__help__run_commands] )) ||
_vmexec__help__run_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec help run commands' commands "$@"
}
(( $+functions[_vmexec__ksm_commands] )) ||
_vmexec__ksm_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec ksm commands' commands "$@"
}
(( $+functions[_vmexec__manpage_commands] )) ||
_vmexec__manpage_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec manpage commands' commands "$@"
}
(( $+functions[_vmexec__run_commands] )) ||
_vmexec__run_commands() {
    local commands; commands=()
    _describe -t commands 'vmexec run commands' commands "$@"
}

if [ "$funcstack[1]" = "_vmexec" ]; then
    _vmexec "$@"
else
    compdef _vmexec vmexec
fi
