#compdef systemd-boot-friend

autoload -U is-at-least

_systemd-boot-friend() {
    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[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'-V[Print version information]' \
'--version[Print version information]' \
":: :_systemd-boot-friend_commands" \
"*::: :->systemd-boot-friend-rs" \
&& ret=0
    case $state in
    (systemd-boot-friend-rs)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:systemd-boot-friend-command-$line[1]:"
        case $line[1] in
            (init)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(update)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(install-kernel)
_arguments "${_arguments_options[@]}" \
'-f[force overwrite the entry config or not]' \
'--force[force overwrite the entry config or not]' \
'-h[Print help information]' \
'--help[Print help information]' \
'::target:' \
&& ret=0
;;
(remove-kernel)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::target:' \
&& ret=0
;;
(list-available)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(list-installed)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_systemd-boot-friend_commands] )) ||
_systemd-boot-friend_commands() {
    local commands; commands=(
'init:Initialize systemd-boot-friend' \
'update:Install all kernels and update boot entries' \
'install-kernel:Install the kernel specified' \
'remove-kernel:Remove the kernel specified' \
'list-available:List all available kernels' \
'list-installed:List all installed kernels' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'systemd-boot-friend commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__help_commands] )) ||
_systemd-boot-friend__help_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend help commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__init_commands] )) ||
_systemd-boot-friend__init_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend init commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__install-kernel_commands] )) ||
_systemd-boot-friend__install-kernel_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend install-kernel commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__list-available_commands] )) ||
_systemd-boot-friend__list-available_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend list-available commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__list-installed_commands] )) ||
_systemd-boot-friend__list-installed_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend list-installed commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__remove-kernel_commands] )) ||
_systemd-boot-friend__remove-kernel_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend remove-kernel commands' commands "$@"
}
(( $+functions[_systemd-boot-friend__update_commands] )) ||
_systemd-boot-friend__update_commands() {
    local commands; commands=()
    _describe -t commands 'systemd-boot-friend update commands' commands "$@"
}

_systemd-boot-friend "$@"
