#compdef hatch

function _hatch {

    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        "-h[show help]" \
        "--help[show help]" \
        "--version[Show version]" \
        "-v[Show version]" \
        "--silent[Don't output to stdout]" \
        "--verbose[Output a lot to stdout]" \
        "--config-file=[Path to configuration file]:file:_files" \
        "1: :(website api)" \
        "*::arg:->args"

    case $line[1] in
        website)
            _hatch_website_command
            ;;
        api)
            ;;
    esac
}

function _hatch_website_command {

    local curcontext="$curcontext" state line
    typeset -A opt_args

    _arguments -C \
        "1: :(serve deploy)" \
        "*::arg:->args"

    case $line[1] in
        deploy)
            _arguments \
                "--path=[Path to the website to deploy]:filename:_files" \
                "--domain=[Custom domain name]" \
                "--name=[Custom bucket name]"
            ;;
        api)
            ;;
    esac
}

_hatch '$@'
