#compdef autogit

autoload -U is-at-least

_autogit() {
    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]' \
":: :_autogit_commands" \
"*::: :->autogit" \
&& ret=0
    case $state in
    (autogit)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:autogit-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
'-m+[Commit message template (default\: "Auto-commit\: {timestamp}")]:MESSAGE:_default' \
'--message=[Commit message template (default\: "Auto-commit\: {timestamp}")]:MESSAGE:_default' \
'-i+[Check interval in seconds (optional, uses daemon default if not set)]:INTERVAL:_default' \
'--interval=[Check interval in seconds (optional, uses daemon default if not set)]:INTERVAL:_default' \
'-h[Print help]' \
'--help[Print help]' \
':path -- Path to the git repository:_default' \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':path -- Path to the repository to remove:_default' \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(enable)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':path -- Path to the repository:_default' \
&& ret=0
;;
(disable)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
':path -- Path to the repository:_default' \
&& ret=0
;;
(interval)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
'::seconds -- Interval in seconds (if not provided, shows current interval):_default' \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(now)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(suspend)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(resume)
_arguments "${_arguments_options[@]}" : \
'-h[Print help]' \
'--help[Print help]' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
":: :_autogit__help_commands" \
"*::: :->help" \
&& ret=0

    case $state in
    (help)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:autogit-help-command-$line[1]:"
        case $line[1] in
            (add)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(remove)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(list)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(enable)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(disable)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(interval)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(status)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(edit)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(now)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(suspend)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(resume)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
&& ret=0
;;
        esac
    ;;
esac
;;
        esac
    ;;
esac
}

(( $+functions[_autogit_commands] )) ||
_autogit_commands() {
    local commands; commands=(
'add:Add a repository to auto-commit' \
'remove:Remove a repository from auto-commit' \
'list:List all configured repositories' \
'enable:Enable auto-commit for a repository' \
'disable:Disable auto-commit for a repository' \
'interval:Set or show the global check interval' \
'status:Show current configuration' \
'edit:Edit configuration file in \$EDITOR' \
'now:Trigger an immediate check and commit cycle' \
'suspend:Suspend the daemon (stop automatic syncing)' \
'resume:Resume the daemon (restart automatic syncing)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'autogit commands' commands "$@"
}
(( $+functions[_autogit__add_commands] )) ||
_autogit__add_commands() {
    local commands; commands=()
    _describe -t commands 'autogit add commands' commands "$@"
}
(( $+functions[_autogit__disable_commands] )) ||
_autogit__disable_commands() {
    local commands; commands=()
    _describe -t commands 'autogit disable commands' commands "$@"
}
(( $+functions[_autogit__edit_commands] )) ||
_autogit__edit_commands() {
    local commands; commands=()
    _describe -t commands 'autogit edit commands' commands "$@"
}
(( $+functions[_autogit__enable_commands] )) ||
_autogit__enable_commands() {
    local commands; commands=()
    _describe -t commands 'autogit enable commands' commands "$@"
}
(( $+functions[_autogit__help_commands] )) ||
_autogit__help_commands() {
    local commands; commands=(
'add:Add a repository to auto-commit' \
'remove:Remove a repository from auto-commit' \
'list:List all configured repositories' \
'enable:Enable auto-commit for a repository' \
'disable:Disable auto-commit for a repository' \
'interval:Set or show the global check interval' \
'status:Show current configuration' \
'edit:Edit configuration file in \$EDITOR' \
'now:Trigger an immediate check and commit cycle' \
'suspend:Suspend the daemon (stop automatic syncing)' \
'resume:Resume the daemon (restart automatic syncing)' \
'help:Print this message or the help of the given subcommand(s)' \
    )
    _describe -t commands 'autogit help commands' commands "$@"
}
(( $+functions[_autogit__help__add_commands] )) ||
_autogit__help__add_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help add commands' commands "$@"
}
(( $+functions[_autogit__help__disable_commands] )) ||
_autogit__help__disable_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help disable commands' commands "$@"
}
(( $+functions[_autogit__help__edit_commands] )) ||
_autogit__help__edit_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help edit commands' commands "$@"
}
(( $+functions[_autogit__help__enable_commands] )) ||
_autogit__help__enable_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help enable commands' commands "$@"
}
(( $+functions[_autogit__help__help_commands] )) ||
_autogit__help__help_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help help commands' commands "$@"
}
(( $+functions[_autogit__help__interval_commands] )) ||
_autogit__help__interval_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help interval commands' commands "$@"
}
(( $+functions[_autogit__help__list_commands] )) ||
_autogit__help__list_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help list commands' commands "$@"
}
(( $+functions[_autogit__help__now_commands] )) ||
_autogit__help__now_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help now commands' commands "$@"
}
(( $+functions[_autogit__help__remove_commands] )) ||
_autogit__help__remove_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help remove commands' commands "$@"
}
(( $+functions[_autogit__help__resume_commands] )) ||
_autogit__help__resume_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help resume commands' commands "$@"
}
(( $+functions[_autogit__help__status_commands] )) ||
_autogit__help__status_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help status commands' commands "$@"
}
(( $+functions[_autogit__help__suspend_commands] )) ||
_autogit__help__suspend_commands() {
    local commands; commands=()
    _describe -t commands 'autogit help suspend commands' commands "$@"
}
(( $+functions[_autogit__interval_commands] )) ||
_autogit__interval_commands() {
    local commands; commands=()
    _describe -t commands 'autogit interval commands' commands "$@"
}
(( $+functions[_autogit__list_commands] )) ||
_autogit__list_commands() {
    local commands; commands=()
    _describe -t commands 'autogit list commands' commands "$@"
}
(( $+functions[_autogit__now_commands] )) ||
_autogit__now_commands() {
    local commands; commands=()
    _describe -t commands 'autogit now commands' commands "$@"
}
(( $+functions[_autogit__remove_commands] )) ||
_autogit__remove_commands() {
    local commands; commands=()
    _describe -t commands 'autogit remove commands' commands "$@"
}
(( $+functions[_autogit__resume_commands] )) ||
_autogit__resume_commands() {
    local commands; commands=()
    _describe -t commands 'autogit resume commands' commands "$@"
}
(( $+functions[_autogit__status_commands] )) ||
_autogit__status_commands() {
    local commands; commands=()
    _describe -t commands 'autogit status commands' commands "$@"
}
(( $+functions[_autogit__suspend_commands] )) ||
_autogit__suspend_commands() {
    local commands; commands=()
    _describe -t commands 'autogit suspend commands' commands "$@"
}

if [ "$funcstack[1]" = "_autogit" ]; then
    _autogit "$@"
else
    compdef _autogit autogit
fi
