#compdef bombadil

autoload -U is-at-least

_bombadil() {
    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]' \
":: :_bombadil_commands" \
"*::: :->Toml Bombadil" \
&& ret=0
    case $state in
    (Toml Bombadil)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:bombadil-command-$line[1]:"
        case $line[1] in
            (install)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
'::config -- Path to your dotfile directory:' \
&& ret=0
;;
(clone)
_arguments "${_arguments_options[@]}" \
'-r+[Remote repository address, either http or ssh]:REMOTE: ' \
'--remote=[Remote repository address, either http or ssh]:REMOTE: ' \
'-t+[Target destination, repository name by default]:TARGET: ' \
'--target=[Target destination, repository name by default]:TARGET: ' \
'*-p+[A list of comma separated profiles to activate]:PROFILES: ' \
'*--profiles=[A list of comma separated profiles to activate]:PROFILES: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(link)
_arguments "${_arguments_options[@]}" \
'*-p+[A list of comma separated profiles to activate]:PROFILES: ' \
'*--profiles=[A list of comma separated profiles to activate]:PROFILES: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(unlink)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(watch)
_arguments "${_arguments_options[@]}" \
'*-p+[A list of comma separated profiles to activate]:PROFILES: ' \
'*--profiles=[A list of comma separated profiles to activate]:PROFILES: ' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(add-secret)
_arguments "${_arguments_options[@]}" \
'-k+[Key of the secret variable to create]:KEY: ' \
'--key=[Key of the secret variable to create]:KEY: ' \
'-v+[]:VALUE: ' \
'--value=[]:VALUE: ' \
'-f+[Path of the var file to modify]:FILE: ' \
'--file=[Path of the var file to modify]:FILE: ' \
'-a[Get the secret value from stdin]' \
'--ask[Get the secret value from stdin]' \
'-h[Print help information]' \
'--help[Print help information]' \
&& ret=0
;;
(get)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':value:(dots prehooks posthooks path profiles vars secrets)' \
'*::profiles:' \
&& ret=0
;;
(generate-completions)
_arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
':type -- Type of completions to generate:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'*::subcommand -- The subcommand whose help message to display:' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_bombadil_commands] )) ||
_bombadil_commands() {
    local commands; commands=(
'install:Link a given dotfile directory config to "XDG_CONFIG_DIR/bombadil.toml"' \
'clone:Install dotfiles from a remote git repository to a target folder' \
'link:Symlink a copy of your dotfiles and inject variables according to bombadil.toml config' \
'unlink:Remove all symlinks defined in your bombadil.toml' \
'watch:Watch dotfiles and automatically run link on changes' \
'add-secret:Add a secret var to bombadil environment' \
'get:Get metadata about dots, hooks, path, profiles, or vars' \
'generate-completions:Generate shell completions Generate shell completions' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'bombadil commands' commands "$@"
}
(( $+functions[_bombadil__add-secret_commands] )) ||
_bombadil__add-secret_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil add-secret commands' commands "$@"
}
(( $+functions[_bombadil__clone_commands] )) ||
_bombadil__clone_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil clone commands' commands "$@"
}
(( $+functions[_bombadil__generate-completions_commands] )) ||
_bombadil__generate-completions_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil generate-completions commands' commands "$@"
}
(( $+functions[_bombadil__get_commands] )) ||
_bombadil__get_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil get commands' commands "$@"
}
(( $+functions[_bombadil__help_commands] )) ||
_bombadil__help_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil help commands' commands "$@"
}
(( $+functions[_bombadil__install_commands] )) ||
_bombadil__install_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil install commands' commands "$@"
}
(( $+functions[_bombadil__link_commands] )) ||
_bombadil__link_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil link commands' commands "$@"
}
(( $+functions[_bombadil__unlink_commands] )) ||
_bombadil__unlink_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil unlink commands' commands "$@"
}
(( $+functions[_bombadil__watch_commands] )) ||
_bombadil__watch_commands() {
    local commands; commands=()
    _describe -t commands 'bombadil watch commands' commands "$@"
}

_bombadil "$@"
