#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[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints 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[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'::CONFIG -- Path to your dotfile directory:_files' \
&& ret=0
;;
(clone)
_arguments "${_arguments_options[@]}" \
'-t+[Target destination, repository name by default]' \
'--target=[Target destination, repository name by default]' \
'*-p+[A list of comma separated profiles to activate]' \
'*--profiles=[A list of comma separated profiles to activate]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
':remote -- Remote repository address, either http or ssh:_files' \
&& ret=0
;;
(link)
_arguments "${_arguments_options[@]}" \
'*-p+[A list of comma separated profiles to activate]: :()' \
'*--profiles=[A list of comma separated profiles to activate]: :()' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(unlink)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(add-secret)
_arguments "${_arguments_options[@]}" \
'-k+[Key of the secret variable to create]' \
'--key=[Key of the secret variable to create]' \
'-v+[Value of the secret variable to create]' \
'--value=[Value of the secret variable to create]' \
'-f+[Path of the var file to modify]' \
'--file=[Path of the var file to modify]' \
'-a[Get the secret value from stdin]' \
'--ask[Get the secret value from stdin]' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& ret=0
;;
(get)
_arguments "${_arguments_options[@]}" \
'*-p+[Get metadata for specific profiles]: :()' \
'*--profiles=[Get metadata for specific profiles]: :()' \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
'::value -- Metadata to get:(dots prehooks posthooks path profiles vars secrets)' \
&& ret=0
;;
(generate-completions)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
':type -- Type of completions to generate:(bash elvish fish zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" \
'-h[Prints help information]' \
'--help[Prints help information]' \
'-V[Prints version information]' \
'--version[Prints version information]' \
&& 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" \
"add-secret:Add a secret var to bombadil environment" \
"get:Get metadata about dots, hooks, path, profiles, or vars" \
"generate-completions:Generate shell completions" \
"help:Prints 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 "$@"
}

_bombadil "$@"