#compdef deadbranch

autoload -U is-at-least

_deadbranch() {
    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]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_deadbranch_commands" \
"*::: :->deadbranch" \
&& ret=0
    case $state in
    (deadbranch)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
'-d+[Only show branches older than N days (default\: from config or 30)]:DAYS:_default' \
'--days=[Only show branches older than N days (default\: from config or 30)]:DAYS:_default' \
'--local[Only show local branches]' \
'(--local)--remote[Only show remote branches]' \
'--merged[Only show merged branches]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
'-d+[Only delete branches older than N days (default\: from config or 30)]:DAYS:_default' \
'--days=[Only delete branches older than N days (default\: from config or 30)]:DAYS:_default' \
'--merged[Only delete merged branches (this is the default behavior)]' \
'--force[Force delete unmerged branches (dangerous!)]' \
'(-i --interactive)--dry-run[Show what would be deleted without doing it]' \
'--local[Only delete local branches]' \
'(--local)--remote[Only delete remote branches]' \
'(-i --interactive)-y[Skip confirmation prompts (useful for scripts)]' \
'(-i --interactive)--yes[Skip confirmation prompts (useful for scripts)]' \
'-i[Open interactive TUI for branch selection]' \
'--interactive[Open interactive TUI for branch selection]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_deadbranch__config_commands" \
"*::: :->config" \
&& ret=0

    case $state in
    (config)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-config-command-$line[1]:"
        case $line[1] in
            (set)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':key -- Configuration key (e.g., default-days, protected-branches, default-branch, exclude-patterns):_default' \
'*::values -- Configuration value(s) - use multiple arguments for lists Example\: config set exclude-patterns "wip/*" "draft/*" "temp/*":_default' \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(reset)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_deadbranch__config__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-config-help-command-$line[1]:"
        case $line[1] in
            (set)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(reset)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(backup)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_deadbranch__backup_commands" \
"*::: :->backup" \
&& ret=0

    case $state in
    (backup)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-backup-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
'--repo=[Show backups for a specific repository by name]:REPO:_default' \
'(--repo)--current[Only show backups for current repository]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" : \
'--from=[Restore from a specific backup file (defaults to most recent)]:FROM:_default' \
'--as=[Restore with a different branch name]:NAME:_default' \
'--force[Overwrite existing branch if it exists]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':branch -- Name of the branch to restore:_default' \
&& ret=0
;;
(stats)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
'--repo=[Clean backups for a specific repository by name]:REPO:_default' \
'--keep=[Number of most recent backups to keep (default\: 10)]:KEEP:_default' \
'(--repo)--current[Clean backups for current repository]' \
'--dry-run[Show what would be deleted without doing it]' \
'-y[Skip confirmation prompt]' \
'--yes[Skip confirmation prompt]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_deadbranch__backup__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-backup-help-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(stats)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
;;
(stats)
_arguments "${_arguments_options[@]}" : \
'-d+[Treat branches older than N days as stale (default\: from config or 30)]:DAYS:_default' \
'--days=[Treat branches older than N days as stale (default\: from config or 30)]:DAYS:_default' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':shell -- Shell to generate completions for:(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_deadbranch__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-help-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(config)
_arguments "${_arguments_options[@]}" : \
":: :_deadbranch__help__config_commands" \
"*::: :->config" \
&& ret=0

    case $state in
    (config)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-help-config-command-$line[1]:"
        case $line[1] in
            (set)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(show)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(reset)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(backup)
_arguments "${_arguments_options[@]}" : \
":: :_deadbranch__help__backup_commands" \
"*::: :->backup" \
&& ret=0

    case $state in
    (backup)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:deadbranch-help-backup-command-$line[1]:"
        case $line[1] in
            (list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(restore)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(stats)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(clean)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
(stats)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(completions)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_deadbranch_commands] )) ||
_deadbranch_commands() {
    local commands; commands=(
'list:List stale branches' \
'clean:Delete stale branches (merged only by default, use --force for unmerged)' \
'config:Manage configuration' \
'backup:Manage backups' \
'stats:Show repository branch statistics' \
'completions:Generate shell completion scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch commands' commands "$@"
}
(( $+functions[_deadbranch__backup_commands] )) ||
_deadbranch__backup_commands() {
    local commands; commands=(
'list:List available backups' \
'restore:Restore a branch from backup' \
'stats:Show backup storage statistics' \
'clean:Remove old backups, keeping the most recent ones' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch backup commands' commands "$@"
}
(( $+functions[_deadbranch__backup__clean_commands] )) ||
_deadbranch__backup__clean_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup clean commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help_commands] )) ||
_deadbranch__backup__help_commands() {
    local commands; commands=(
'list:List available backups' \
'restore:Restore a branch from backup' \
'stats:Show backup storage statistics' \
'clean:Remove old backups, keeping the most recent ones' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch backup help commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help__clean_commands] )) ||
_deadbranch__backup__help__clean_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup help clean commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help__help_commands] )) ||
_deadbranch__backup__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup help help commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help__list_commands] )) ||
_deadbranch__backup__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup help list commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help__restore_commands] )) ||
_deadbranch__backup__help__restore_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup help restore commands' commands "$@"
}
(( $+functions[_deadbranch__backup__help__stats_commands] )) ||
_deadbranch__backup__help__stats_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup help stats commands' commands "$@"
}
(( $+functions[_deadbranch__backup__list_commands] )) ||
_deadbranch__backup__list_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup list commands' commands "$@"
}
(( $+functions[_deadbranch__backup__restore_commands] )) ||
_deadbranch__backup__restore_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup restore commands' commands "$@"
}
(( $+functions[_deadbranch__backup__stats_commands] )) ||
_deadbranch__backup__stats_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch backup stats commands' commands "$@"
}
(( $+functions[_deadbranch__clean_commands] )) ||
_deadbranch__clean_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch clean commands' commands "$@"
}
(( $+functions[_deadbranch__completions_commands] )) ||
_deadbranch__completions_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch completions commands' commands "$@"
}
(( $+functions[_deadbranch__config_commands] )) ||
_deadbranch__config_commands() {
    local commands; commands=(
'set:Set a configuration value' \
'show:Show current configuration' \
'edit:Open config file in \$EDITOR' \
'reset:Reset configuration to defaults' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch config commands' commands "$@"
}
(( $+functions[_deadbranch__config__edit_commands] )) ||
_deadbranch__config__edit_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config edit commands' commands "$@"
}
(( $+functions[_deadbranch__config__help_commands] )) ||
_deadbranch__config__help_commands() {
    local commands; commands=(
'set:Set a configuration value' \
'show:Show current configuration' \
'edit:Open config file in \$EDITOR' \
'reset:Reset configuration to defaults' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch config help commands' commands "$@"
}
(( $+functions[_deadbranch__config__help__edit_commands] )) ||
_deadbranch__config__help__edit_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config help edit commands' commands "$@"
}
(( $+functions[_deadbranch__config__help__help_commands] )) ||
_deadbranch__config__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config help help commands' commands "$@"
}
(( $+functions[_deadbranch__config__help__reset_commands] )) ||
_deadbranch__config__help__reset_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config help reset commands' commands "$@"
}
(( $+functions[_deadbranch__config__help__set_commands] )) ||
_deadbranch__config__help__set_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config help set commands' commands "$@"
}
(( $+functions[_deadbranch__config__help__show_commands] )) ||
_deadbranch__config__help__show_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config help show commands' commands "$@"
}
(( $+functions[_deadbranch__config__reset_commands] )) ||
_deadbranch__config__reset_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config reset commands' commands "$@"
}
(( $+functions[_deadbranch__config__set_commands] )) ||
_deadbranch__config__set_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config set commands' commands "$@"
}
(( $+functions[_deadbranch__config__show_commands] )) ||
_deadbranch__config__show_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch config show commands' commands "$@"
}
(( $+functions[_deadbranch__help_commands] )) ||
_deadbranch__help_commands() {
    local commands; commands=(
'list:List stale branches' \
'clean:Delete stale branches (merged only by default, use --force for unmerged)' \
'config:Manage configuration' \
'backup:Manage backups' \
'stats:Show repository branch statistics' \
'completions:Generate shell completion scripts' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'deadbranch help commands' commands "$@"
}
(( $+functions[_deadbranch__help__backup_commands] )) ||
_deadbranch__help__backup_commands() {
    local commands; commands=(
'list:List available backups' \
'restore:Restore a branch from backup' \
'stats:Show backup storage statistics' \
'clean:Remove old backups, keeping the most recent ones' \
    )
    _describe -t commands 'deadbranch help backup commands' commands "$@"
}
(( $+functions[_deadbranch__help__backup__clean_commands] )) ||
_deadbranch__help__backup__clean_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help backup clean commands' commands "$@"
}
(( $+functions[_deadbranch__help__backup__list_commands] )) ||
_deadbranch__help__backup__list_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help backup list commands' commands "$@"
}
(( $+functions[_deadbranch__help__backup__restore_commands] )) ||
_deadbranch__help__backup__restore_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help backup restore commands' commands "$@"
}
(( $+functions[_deadbranch__help__backup__stats_commands] )) ||
_deadbranch__help__backup__stats_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help backup stats commands' commands "$@"
}
(( $+functions[_deadbranch__help__clean_commands] )) ||
_deadbranch__help__clean_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help clean commands' commands "$@"
}
(( $+functions[_deadbranch__help__completions_commands] )) ||
_deadbranch__help__completions_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help completions commands' commands "$@"
}
(( $+functions[_deadbranch__help__config_commands] )) ||
_deadbranch__help__config_commands() {
    local commands; commands=(
'set:Set a configuration value' \
'show:Show current configuration' \
'edit:Open config file in \$EDITOR' \
'reset:Reset configuration to defaults' \
    )
    _describe -t commands 'deadbranch help config commands' commands "$@"
}
(( $+functions[_deadbranch__help__config__edit_commands] )) ||
_deadbranch__help__config__edit_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help config edit commands' commands "$@"
}
(( $+functions[_deadbranch__help__config__reset_commands] )) ||
_deadbranch__help__config__reset_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help config reset commands' commands "$@"
}
(( $+functions[_deadbranch__help__config__set_commands] )) ||
_deadbranch__help__config__set_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help config set commands' commands "$@"
}
(( $+functions[_deadbranch__help__config__show_commands] )) ||
_deadbranch__help__config__show_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help config show commands' commands "$@"
}
(( $+functions[_deadbranch__help__help_commands] )) ||
_deadbranch__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help help commands' commands "$@"
}
(( $+functions[_deadbranch__help__list_commands] )) ||
_deadbranch__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help list commands' commands "$@"
}
(( $+functions[_deadbranch__help__stats_commands] )) ||
_deadbranch__help__stats_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch help stats commands' commands "$@"
}
(( $+functions[_deadbranch__list_commands] )) ||
_deadbranch__list_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch list commands' commands "$@"
}
(( $+functions[_deadbranch__stats_commands] )) ||
_deadbranch__stats_commands() {
    local commands; commands=()
    _describe -t commands 'deadbranch stats commands' commands "$@"
}

if [ "$funcstack[1]" = "_deadbranch" ]; then
    _deadbranch "$@"
else
    compdef _deadbranch deadbranch
fi
