#compdef git-edit-date

_git_edit_date() {
    local -a commands
    commands=(
        'export:Export HEAD commit history to CSV'
        'apply:Rewrite commit metadata from edited CSV'
        'completion:Generate shell completion script'
        'help:Show help'
    )

    _arguments -C \
        '1: :->command' \
        '*:: :->args'

    case $state in
        command)
            _describe 'command' commands
            ;;
        args)
            case $words[1] in
                export)
                    _arguments \
                        '-o[Output CSV file]:file:_files' \
                        '-repo[Path to git repository]:directory:_directories'
                    ;;
                apply)
                    _arguments \
                        '-file[Path to edited CSV file]:file:_files' \
                        '-repo[Path to git repository]:directory:_directories' \
                        '-allow-dirty[Allow dirty working tree]'
                    ;;
                completion)
                    _arguments '1: :(bash zsh)'
                    ;;
            esac
            ;;
    esac
}

_git_edit_date "$@"
