#compdef create-api
local context state state_descr line
_create_api_commandname=$words[1]
typeset -A opt_args

_create-api() {
    integer ret=1
    local -a args
    args+=(
        '--version[Show the version.]'
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S $args[@] && ret=0
    case $state in
        (command)
            local subcommands
            subcommands=(
                'generate:'
                'help:Show subcommand help information.'
            )
            _describe "subcommand" subcommands
            ;;
        (arg)
            case ${words[1]} in
                (generate)
                    _create-api_generate
                    ;;
                (help)
                    _create-api_help
                    ;;
            esac
            ;;
    esac

    return ret
}

_create-api_generate() {
    integer ret=1
    local -a args
    args+=(
        ':input:_files -g '"'"'*.yml *.yaml *.json'"'"''
        '--output[The directory where generated outputs are written]:output:_files -/'
        '--config[The path to the generator configuration.]:config:_files -g '"'"'*.yml *.yaml *.json'"'"''
        '--config-option[Option overrides to be applied when generating.]:config-option:'
        '(--verbose -v)'{--verbose,-v}'[Enables verbose log messages]'
        '--strict[Treats warnings as errors and fails generation]'
        '--allow-errors[Ignore errors that occur during generation and continue if possible]'
        '(--clean -c)'{--clean,-c}'[Removes the output directory before writing generated outputs]'
        '--single-threaded[Disables parallelization]'
        '--measure[Measure performance of individual operations and log timings]'
        '--version[Show the version.]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S $args[@] && ret=0

    return ret
}

_create-api_help() {
    integer ret=1
    local -a args
    args+=(
        ':subcommands:'
        '--version[Show the version.]'
    )
    _arguments -w -s -S $args[@] && ret=0

    return ret
}


_custom_completion() {
    local completions=("${(@f)$($*)}")
    _describe '' completions
}

_create-api
