#compdef cubic

autoload -U is-at-least

_cubic() {
    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[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_cubic_commands" \
"*::: :->cubic" \
&& ret=0
    case $state in
    (cubic)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:cubic-command-$line[1]:"
        case $line[1] in
            (run)
_arguments "${_arguments_options[@]}" : \
'-i+[VM image name (e.g. '\''debian\:trixie'\'')]:IMAGE:_default' \
'--image=[VM image name (e.g. '\''debian\:trixie'\'')]:IMAGE:_default' \
'-u+[Username (default\: '\''cubic'\'')]:USER:_default' \
'--user=[Username (default\: '\''cubic'\'')]:USER:_default' \
'-c+[Number of vCPUs for the VM instance]:CPUS:_default' \
'--cpus=[Number of vCPUs for the VM instance]:CPUS:_default' \
'-m+[Memory amount of the VM instance]:MEMORY:_default' \
'--memory=[Memory amount of the VM instance]:MEMORY:_default' \
'-d+[Disk size of the VM instance]:DISK:_default' \
'--disk=[Disk size of the VM instance]:DISK:_default' \
'*-p+[Forward ports from guest to host (e.g. -p 8000\:80 or -p 9000\:90/tcp)]:PORT:_default' \
'*--port=[Forward ports from guest to host (e.g. -p 8000\:80 or -p 9000\:90/tcp)]:PORT:_default' \
'-e+[Execute a command once on the first boot (e.g. "sudo apt install ...")]:EXECUTE:_default' \
'--execute=[Execute a command once on the first boot (e.g. "sudo apt install ...")]:EXECUTE:_default' \
'--isolate[Isolate the VM instance from network]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':instance_name -- VM instance name (e.g. '\''my-instance'\''):_default' \
&& ret=0
;;
(create)
_arguments "${_arguments_options[@]}" : \
'-i+[VM image name (e.g. '\''debian\:trixie'\'')]:IMAGE:_default' \
'--image=[VM image name (e.g. '\''debian\:trixie'\'')]:IMAGE:_default' \
'-u+[Username (default\: '\''cubic'\'')]:USER:_default' \
'--user=[Username (default\: '\''cubic'\'')]:USER:_default' \
'-c+[Number of vCPUs for the VM instance]:CPUS:_default' \
'--cpus=[Number of vCPUs for the VM instance]:CPUS:_default' \
'-m+[Memory amount of the VM instance]:MEMORY:_default' \
'--memory=[Memory amount of the VM instance]:MEMORY:_default' \
'-d+[Disk size of the VM instance]:DISK:_default' \
'--disk=[Disk size of the VM instance]:DISK:_default' \
'*-p+[Forward ports from guest to host (e.g. -p 8000\:80 or -p 9000\:90/tcp)]:PORT:_default' \
'*--port=[Forward ports from guest to host (e.g. -p 8000\:80 or -p 9000\:90/tcp)]:PORT:_default' \
'-e+[Execute a command once on the first boot (e.g. "sudo apt install ...")]:EXECUTE:_default' \
'--execute=[Execute a command once on the first boot (e.g. "sudo apt install ...")]:EXECUTE:_default' \
'--isolate[Isolate the VM instance from network]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':instance_name -- VM instance name (e.g. '\''my-instance'\''):_default' \
&& ret=0
;;
(instances)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(images)
_arguments "${_arguments_options[@]}" : \
'-a[Show all images]' \
'--all[Show all images]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(ports)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':name -- Name of the virtual machine image or instance:_default' \
&& ret=0
;;
(modify)
_arguments "${_arguments_options[@]}" : \
'-c+[Number of CPUs for the virtual machine instance]:CPUS:_default' \
'--cpus=[Number of CPUs for the virtual machine instance]:CPUS:_default' \
'-m+[Memory size of the virtual machine instance (e.g. 1G for 1 gigabyte)]:MEMORY:_default' \
'--memory=[Memory size of the virtual machine instance (e.g. 1G for 1 gigabyte)]:MEMORY:_default' \
'-d+[Disk size of the virtual machine instance  (e.g. 10G for 10 gigabytes)]:DISK:_default' \
'--disk=[Disk size of the virtual machine instance  (e.g. 10G for 10 gigabytes)]:DISK:_default' \
'*-p+[Add port forwarding rule (format\: \[host_ip\:\]host_port\:guest_port\[/(udp|tcp)\], e.g. -p 8000\:80/tcp)]:PORT:_default' \
'*--port=[Add port forwarding rule (format\: \[host_ip\:\]host_port\:guest_port\[/(udp|tcp)\], e.g. -p 8000\:80/tcp)]:PORT:_default' \
'*-P+[Remove port forwarding rule (e.g. -P 8000\:80)]:RM_PORT:_default' \
'*--rm-port=[Remove port forwarding rule (e.g. -P 8000\:80)]:RM_PORT:_default' \
'--isolate[Isolate VM instance from network]' \
'--no-isolate[Do not isolate VM instance from network (default)]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':instance -- Name of the virtual machine instance:_default' \
&& ret=0
;;
(console)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':instance -- Name of the virtual machine instance:_default' \
&& ret=0
;;
(ssh)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':target -- Target instance (format\: \[username@\]instance, e.g. '\''myinstance'\'' or '\''cubic@myinstance'\''):_default' \
'::cmd -- Command to execute in the virtual machine instance:_default' \
&& ret=0
;;
(scp)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':from -- Source of the data to copy:_default' \
':to -- Target of the data to copy:_default' \
&& ret=0
;;
(exec)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':target -- Target instance (format\: \[username@\]instance, e.g. '\''myinstance'\'' or '\''cubic@myinstance'\''):_default' \
':cmd -- Command to execute in the virtual machine instance:_default' \
&& ret=0
;;
(start)
_arguments "${_arguments_options[@]}" : \
'--qemu-args=[Pass additional QEMU arguments]:QEMU_ARGS:_default' \
'-w[Wait until the VM instance has started]' \
'--wait[Wait until the VM instance has started]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::instances -- Name of the virtual machine instances to start:_default' \
&& ret=0
;;
(stop)
_arguments "${_arguments_options[@]}" : \
'-a[Stop all virtual machine instances]' \
'--all[Stop all virtual machine instances]' \
'-w[Wait for the virtual machine instance to be stopped]' \
'--wait[Wait for the virtual machine instance to be stopped]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::instances -- Name of the virtual machine instances to stop:_default' \
&& ret=0
;;
(restart)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::instances -- Name of the virtual machine instances to restart:_default' \
&& ret=0
;;
(rename)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':old_name -- Name of the virtual machine instance to rename:_default' \
':new_name -- New name of the virtual machine instance:_default' \
&& ret=0
;;
(clone)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
':name -- Name of the virtual machine instance to clone:_default' \
':new_name -- Name of the copy:_default' \
&& ret=0
;;
(delete)
_arguments "${_arguments_options[@]}" : \
'-f[Delete the VM instances even when running (Deprecated)]' \
'--force[Delete the VM instances even when running (Deprecated)]' \
'-y[Answer all questions with yes]' \
'--yes[Answer all questions with yes]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'*::instances -- Name of the VM instances to delete:_default' \
&& ret=0
;;
(prune)
_arguments "${_arguments_options[@]}" : \
'-y[Answer all questions with yes]' \
'--yes[Answer all questions with yes]' \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-v[Increase logging output]' \
'--verbose[Increase logging output]' \
'-q[Reduce logging output]' \
'--quiet[Reduce logging output]' \
'-h[Print help (see more with '\''--help'\'')]' \
'--help[Print help (see more with '\''--help'\'')]' \
'::shell -- The shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_cubic_commands] )) ||
_cubic_commands() {
    local commands; commands=(
'run:Create and start VM instances' \
'create:Create VM instances' \
'instances:List VM instances' \
'images:List VM images' \
'ports:List ports for VM instances' \
'show:Show VM images and instances' \
'modify:Modify VM instances' \
'console:Open VM instance console' \
'ssh:Connect to VM instances' \
'scp:Copy data between host and VM instances' \
'exec:Execute commands on VM instances' \
'start:Start VM instances' \
'stop:Stop VM instances' \
'restart:Restart VM instances' \
'rename:Rename VM instances' \
'clone:Clone VM instances' \
'delete:Delete VM instances' \
'prune:Clear caches' \
'completions:Generate shell completion scripts' \
    )
    _describe -t commands 'cubic commands' commands "$@"
}
(( $+functions[_cubic__subcmd__clone_commands] )) ||
_cubic__subcmd__clone_commands() {
    local commands; commands=()
    _describe -t commands 'cubic clone commands' commands "$@"
}
(( $+functions[_cubic__subcmd__completions_commands] )) ||
_cubic__subcmd__completions_commands() {
    local commands; commands=()
    _describe -t commands 'cubic completions commands' commands "$@"
}
(( $+functions[_cubic__subcmd__console_commands] )) ||
_cubic__subcmd__console_commands() {
    local commands; commands=()
    _describe -t commands 'cubic console commands' commands "$@"
}
(( $+functions[_cubic__subcmd__create_commands] )) ||
_cubic__subcmd__create_commands() {
    local commands; commands=()
    _describe -t commands 'cubic create commands' commands "$@"
}
(( $+functions[_cubic__subcmd__delete_commands] )) ||
_cubic__subcmd__delete_commands() {
    local commands; commands=()
    _describe -t commands 'cubic delete commands' commands "$@"
}
(( $+functions[_cubic__subcmd__exec_commands] )) ||
_cubic__subcmd__exec_commands() {
    local commands; commands=()
    _describe -t commands 'cubic exec commands' commands "$@"
}
(( $+functions[_cubic__subcmd__images_commands] )) ||
_cubic__subcmd__images_commands() {
    local commands; commands=()
    _describe -t commands 'cubic images commands' commands "$@"
}
(( $+functions[_cubic__subcmd__instances_commands] )) ||
_cubic__subcmd__instances_commands() {
    local commands; commands=()
    _describe -t commands 'cubic instances commands' commands "$@"
}
(( $+functions[_cubic__subcmd__modify_commands] )) ||
_cubic__subcmd__modify_commands() {
    local commands; commands=()
    _describe -t commands 'cubic modify commands' commands "$@"
}
(( $+functions[_cubic__subcmd__ports_commands] )) ||
_cubic__subcmd__ports_commands() {
    local commands; commands=()
    _describe -t commands 'cubic ports commands' commands "$@"
}
(( $+functions[_cubic__subcmd__prune_commands] )) ||
_cubic__subcmd__prune_commands() {
    local commands; commands=()
    _describe -t commands 'cubic prune commands' commands "$@"
}
(( $+functions[_cubic__subcmd__rename_commands] )) ||
_cubic__subcmd__rename_commands() {
    local commands; commands=()
    _describe -t commands 'cubic rename commands' commands "$@"
}
(( $+functions[_cubic__subcmd__restart_commands] )) ||
_cubic__subcmd__restart_commands() {
    local commands; commands=()
    _describe -t commands 'cubic restart commands' commands "$@"
}
(( $+functions[_cubic__subcmd__run_commands] )) ||
_cubic__subcmd__run_commands() {
    local commands; commands=()
    _describe -t commands 'cubic run commands' commands "$@"
}
(( $+functions[_cubic__subcmd__scp_commands] )) ||
_cubic__subcmd__scp_commands() {
    local commands; commands=()
    _describe -t commands 'cubic scp commands' commands "$@"
}
(( $+functions[_cubic__subcmd__show_commands] )) ||
_cubic__subcmd__show_commands() {
    local commands; commands=()
    _describe -t commands 'cubic show commands' commands "$@"
}
(( $+functions[_cubic__subcmd__ssh_commands] )) ||
_cubic__subcmd__ssh_commands() {
    local commands; commands=()
    _describe -t commands 'cubic ssh commands' commands "$@"
}
(( $+functions[_cubic__subcmd__start_commands] )) ||
_cubic__subcmd__start_commands() {
    local commands; commands=()
    _describe -t commands 'cubic start commands' commands "$@"
}
(( $+functions[_cubic__subcmd__stop_commands] )) ||
_cubic__subcmd__stop_commands() {
    local commands; commands=()
    _describe -t commands 'cubic stop commands' commands "$@"
}

if [ "$funcstack[1]" = "_cubic" ]; then
    _cubic "$@"
else
    compdef _cubic cubic
fi
