#compdef skip

__skip_complete() {
    local -ar non_empty_completions=("${@:#(|:*)}")
    local -ar empty_completions=("${(M)@:#(|:*)}")
    _describe -V '' non_empty_completions -- empty_completions -P $'\'\''
}

__skip_custom_complete() {
    local -a completions
    completions=("${(@f)"$("${command_name}" "${@}" "${command_line[@]}")"}")
    if [[ "${#completions[@]}" -gt 1 ]]; then
        __skip_complete "${completions[@]:0:-1}"
    fi
}

__skip_cursor_index_in_current_word() {
    if [[ -z "${QIPREFIX}${IPREFIX}${PREFIX}" ]]; then
        printf 0
    else
        printf %s "${#${(z)LBUFFER}[-1]}"
    fi
}

_skip() {
    emulate -RL zsh -G
    setopt extendedglob nullglob numericglobsort
    unsetopt aliases banghist

    local -xr SAP_SHELL=zsh
    local -x SAP_SHELL_VERSION
    SAP_SHELL_VERSION="$(builtin emulate zsh -c 'printf %s "${ZSH_VERSION}"')"
    local -r SAP_SHELL_VERSION

    local context state state_descr line
    local -A opt_args

    local -r command_name="${words[1]}"
    local -ar command_line=("${words[@]}")
    local -ir current_word_index="$((CURRENT - 1))"

    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'version:Print the skip version'
            'doctor:Evaluate and diagnose Skip development environment'
            'checkup:Run tests to ensure Skip is in working order'
            'upgrade:Upgrade to the latest Skip version'
            'create:Create a new Skip project interactively'
            'init:Initialize a new Skip project'
            'verify:Verify Skip project'
            'icon:Create and manage app icons'
            'android:Build, run, and test Swift packages for Android'
            'export:Export the Gradle project and built artifacts'
            'devices:List connected devices and emulators/simulators'
            'test:Run parity tests and generate reports'
            'help:Show subcommand help information.'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        version|doctor|checkup|upgrade|create|init|verify|icon|android|export|devices|test|help)
            "_skip_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_version() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_doctor() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--native[Check for native SDK]'
        '--no-native[Check for native SDK]'
        '--fail-fast[Fail immediately when an error occurs]'
        '--no-fail-fast[Fail immediately when an error occurs]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_checkup() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-c --configuration)'{-c,--configuration}'[Configuration debug/release]:c:'
        '--double-check[Check twice that sample build outputs produce identical artifacts]'
        '--native[Generate native app when running checkup]'
        '--native-app[Generate native app when running checkup]'
        '--native-model[Generate native module when running checkup]'
        '--fail-fast[Fail immediately when an error occurs]'
        '--no-fail-fast[Fail immediately when an error occurs]'
        '--project-name[Name of checkup project]:name:'
        '--module-name[Name of checkup project module]:module-name:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_upgrade() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_create() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar ___test_case_mode=('testing' 'xctest')
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '(-d --dir)'{-d,--dir}'[Base folder for project creation]:directory:'
        '--resource-path[Resource folder name]:resource-path:'
        '--swift-package-version[Swift version for project]:swift-package-version:'
        '--ios-min-version[Minimum iOS version to target]:ios-min-version:'
        '--macos-min-version[Minimum macOS version to target]:macos-min-version:'
        '--chain[Create library dependencies between modules]'
        '--no-chain[Create library dependencies between modules]'
        '--zero[Add SKIP_ZERO environment check to Package.swift]'
        '--no-zero[Add SKIP_ZERO environment check to Package.swift]'
        '--git-repo[Create a local git repository for the app]'
        '--no-git-repo[Create a local git repository for the app]'
        '--free[Create package with free software license]'
        '--show-tree[Display a file system tree summary of the new files]'
        '--no-show-tree[Display a file system tree summary of the new files]'
        '--kotlincompat[Whether native model should use kotlincompat]'
        '--no-kotlincompat[Whether native model should use kotlincompat]'
        '--bridged[Whether transpiled model should be bridged]'
        '--no-bridged[Whether transpiled model should be bridged]'
        '--module-tests[Whether to create test modules]'
        '--no-module-tests[Whether to create test modules]'
        '--fastlane[Whether to create fastlane metadata]'
        '--no-fastlane[Whether to create fastlane metadata]'
        '--github[Whether to create github metadata]'
        '--no-github[Whether to create github metadata]'
        '--test-case-mode[Test case style\: testing or xctest]:mode:{__skip_complete "${___test_case_mode[@]}"}'
        '--validate-package[Validate generated Package.swift files]'
        '--no-validate-package[Validate generated Package.swift files]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_init() {
    local -i ret=1
    local -ar ___test_case_mode=('testing' 'xctest')
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '(-d --dir)'{-d,--dir}'[Base folder for project creation]:directory:'
        '--resource-path[Resource folder name]:resource-path:'
        '--swift-package-version[Swift version for project]:swift-package-version:'
        '--ios-min-version[Minimum iOS version to target]:ios-min-version:'
        '--macos-min-version[Minimum macOS version to target]:macos-min-version:'
        '--chain[Create library dependencies between modules]'
        '--no-chain[Create library dependencies between modules]'
        '--zero[Add SKIP_ZERO environment check to Package.swift]'
        '--no-zero[Add SKIP_ZERO environment check to Package.swift]'
        '--git-repo[Create a local git repository for the app]'
        '--no-git-repo[Create a local git repository for the app]'
        '--free[Create package with free software license]'
        '--show-tree[Display a file system tree summary of the new files]'
        '--no-show-tree[Display a file system tree summary of the new files]'
        '--kotlincompat[Whether native model should use kotlincompat]'
        '--no-kotlincompat[Whether native model should use kotlincompat]'
        '--bridged[Whether transpiled model should be bridged]'
        '--no-bridged[Whether transpiled model should be bridged]'
        '--module-tests[Whether to create test modules]'
        '--no-module-tests[Whether to create test modules]'
        '--fastlane[Whether to create fastlane metadata]'
        '--no-fastlane[Whether to create fastlane metadata]'
        '--github[Whether to create github metadata]'
        '--no-github[Whether to create github metadata]'
        '--test-case-mode[Test case style\: testing or xctest]:mode:{__skip_complete "${___test_case_mode[@]}"}'
        '--validate-package[Validate generated Package.swift files]'
        '--no-validate-package[Validate generated Package.swift files]'
        '--native-app'
        '--transpiled-app'
        '--native-model'
        '--transpiled-model'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--build[Run the project build]'
        '--no-build[Run the project build]'
        '--test[Run the project tests]'
        '--no-test[Run the project tests]'
        '--verify[Verify the project output]'
        '--no-verify[Verify the project output]'
        ':project-name:'
        '--appid[Embed the library as an app with the given bundle id]:bundleID:'
        '--no-icon[Disable icon generation]'
        '*--icon[Path to icon input file (SVG, PDF, PNG)]:icon:'
        '--icon-background[RGB hexadecimal color for icon background]:hex:'
        '--icon-foreground[RGB hexadecimal color for icon foreground]:hex:'
        '--icon-shadow[The amount of shadow to draw around the target]:decimal:'
        '--icon-inset[The amount of inset to place on the image]:decimal:'
        '--version[Set the initial version to the given value]:version:'
        '--apk[Build the Android .apk file]'
        '--no-apk[Build the Android .apk file]'
        '--ipa[Build the iOS .ipa file]'
        '--no-ipa[Build the iOS .ipa file]'
        '--open-xcode[Open the resulting Xcode project]'
        '--open-gradle[Open the resulting Gradle project]'
        '*:module-names:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_verify() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--project[Project folder]:dir:'
        '--free[Validate free project]'
        '--no-free[Validate free project]'
        '--fastlane[Validate fastlane config]'
        '--no-fastlane[Validate fastlane config]'
        '--fail-fast[Fail immediately when an error occurs]'
        '--no-fail-fast[Fail immediately when an error occurs]'
        '--fix[Attempt to automatically fix issues]'
        '--no-fix[Attempt to automatically fix issues]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_icon() {
    local -i ret=1
    local -ar arg_specs=(
        '(-d --dir)'{-d,--dir}'[Root folder for icon generation]:directory:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--open-preview[Open the generated icons in Preview]'
        '--android[Generate an Android icon set]'
        '--no-android[Generate an Android icon set]'
        '--android-path[Path the Android resources root folder]:path:'
        '--darwin[Generate an Android icon set]'
        '--no-darwin[Generate an Android icon set]'
        '--darwin-path[Path the Darwin icon assets folder]:path:'
        '--foreground[Name or RGB hex color/gradient for icon color]:color:'
        '--background[Name or RGB hex color/gradient for icon background]:color:'
        '--inset[The percentage amount of inset for the shape]:amount:'
        '--shadow[The percentage amount of shadow to dear around the path]:amount:'
        '--random-icon[Create a random icon shape]'
        '--random-background[Create a random icon color]'
        '*:icon-sources:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android() {
    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'build:Build the native project for Android'
            'run:Run the executable target on an Android device or emulator'
            'test:Test the native project on an Android device or emulator'
            'home:Install and manage the Android SDK in ANDROID_HOME'
            'sdk:Manage installation of Swift Android SDK'
            'emulator:Manage Android emulators'
            'toolchain:Manage installation of Swift Android Host Toolchain'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        build|run|test|home|sdk|emulator|toolchain)
            "_skip_android_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_android_build() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '(-d --dir)'{-d,--dir}'[Archive output folder]:directory:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '*:args:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_run() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--android-serial[Android device or emulator serial]:ANDROID_SERIAL:'
        '--android-connect-timeout[Seconds to wait for device boot before installing]:seconds:'
        '--cleanup[Cleanup temporary folders after running]'
        '--no-cleanup[Cleanup temporary folders after running]'
        '--remote-folder[Remote folder on emulator/device for build upload]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '*--env[Environment key/value pairs for remote execution]:key=value:'
        '*--copy[Additional files or folders to copy to Android]:file/folder:'
        '*:args:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_test() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--android-serial[Android device or emulator serial]:ANDROID_SERIAL:'
        '--android-connect-timeout[Seconds to wait for device boot before installing]:seconds:'
        '--cleanup[Cleanup test folders after running]'
        '--no-cleanup[Cleanup test folders after running]'
        '--remote-folder[Remote folder on emulator/device for build upload]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '--testing-library[Testing library name]:library:'
        '*--env[Environment key/value pairs for remote execution]:key=value:'
        '*--copy[Additional files or folders to copy to Android]:file/folder:'
        '--apk[Package and run tests as an Android APK]'
        '--no-apk[Package and run tests as an Android APK]'
        '--event-stream-output-path[Path to write the JSON event stream output]:path:'
        '*:args:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_home() {
    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'install:Install Android SDK Command-line Tools, platform-tools, and emulator in ANDROID_HOME'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        install)
            "_skip_android_home_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_android_home_install() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_sdk() {
    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'list:List the installed Swift Android SDKs'
            'install:Install the native Swift Android SDK'
            'uninstall:Uninstall the Swift Android SDK'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        list|install|uninstall)
            "_skip_android_sdk_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_android_sdk_list() {
    local -i ret=1
    local -ar arg_specs=(
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--remote[List remote SDKs that can be installed]'
        '--devel[Include development SDKs in remote list]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_sdk_install() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '--version[Version of the Swift Android SDK to install (defaults to latest release)]:version:'
        '--ndk-version[Version of the Android NDK to link to the toolchain]:ndk:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '--reinstall[Reinstall the Android SDK]'
        '--verify[Verify Android SDK installation]'
        '--no-verify[Verify Android SDK installation]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_sdk_uninstall() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '--version[Version of the Swift Android SDK to uninstall, or '\''all'\'' to remove all installed versions]:version:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_emulator() {
    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'create:Install and create an Android emulator image'
            'list:List installed Android emulator images (AVDs)'
            'launch:Launch an Android emulator'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        create|list|launch)
            "_skip_android_emulator_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_android_emulator_create() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--android-api-level[Android API emulator level]:level:'
        '--device-profile[Android emulator device profile]:profile:'
        '(-n --name)'{-n,--name}'[Android emulator name]:name:'
        '--package[The full package name of the emulator to install]:package:'
        '--system-image[Android emulator APIs]:image:'
        '--arch[Android emulator architecture]:arch:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_emulator_list() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_emulator_launch() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-n --name)'{-n,--name}'[Android emulator name]:name:'
        '--logcat[Logcat filter (see https\://developer.android.com/tools/logcat)]:filter:'
        '--background[Background the emulator process once it is launched]'
        '--no-background[Background the emulator process once it is launched]'
        '--headless[Run in headless mode]'
        '--no-headless[Run in headless mode]'
        '--android-connect-timeout[Seconds to wait for emulator boot]:seconds:'
        '*:args:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_android_toolchain() {
    local -i ret=1
    local -ar arg_specs=(
        '(-h --help)'{-h,--help}'[Show help information.]'
        '(-): :->command'
        '(-)*:: :->arg'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0
    case "${state}" in
    command)
        local -ar subcommands=(
            'version:Show the version of the Swift Android Host Toolchain'
        )
        _describe -V subcommand subcommands && ret=0
        ;;
    arg)
        case "${words[1]}" in
        version)
            "_skip_android_toolchain_${words[1]}" && ret=0
            ;;
        esac
        ;;
    esac

    return "${ret}"
}

_skip_android_toolchain_version() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--swift-version[Swift version to use]:v:'
        '--sdk[Swift Android SDK path]:path:'
        '--ndk[Android NDK path]:path:'
        '--toolchain[Swift toolchain path]:path:'
        '--package-path[Path to the package to run]:path:'
        '--scratch-path[Custom scratch directory path]:.build:'
        '*-Xswiftc[Pass flag through to all Swift compiler invocations]:Xswiftc:'
        '*-Xcc[Pass flag through to all C compiler invocations]:Xcc:'
        '*-Xlinker[Pass flag through to all linker invocations]:Xlinker:'
        '*-Xcxx[Pass flag through to all C++ compiler invocations]:Xcxx:'
        '(-c --configuration)'{-c,--configuration}'[Build with configuration]:debug:'
        '*--arch[Destination architectures]:arch:{__skip_complete "${___arch[@]}"}'
        '--android-api-level[Android API level]:level:'
        '--swift-sdk-home[Root path for Swift SDK]:path:'
        '--bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--no-bridge[Enable SKIP_BRIDGE bridging to Kotlin]'
        '--aggregate[Enable bundling all libraries into a single shared object]'
        '--no-aggregate[Enable bundling all libraries into a single shared object]'
        '--prune[Prune non-dependent libraries from build output]'
        '--no-prune[Prune non-dependent libraries from build output]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_export() {
    local -i ret=1
    local -ar ___arch=('automatic' 'current' 'default' 'all' 'aarch64' 'armv7' 'x86_64')
    local -ar arg_specs=(
        '(-d --dir)'{-d,--dir}'[Export output folder]:directory:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '--package[App package name]:package-name:'
        '*--module[Modules to export]:ModuleName:'
        '--project[Project folder]:dir:'
        '--summary-file[Output summary path]:file:'
        '--build[Build the Swift project before exporting]'
        '--no-build[Build the Swift project before exporting]'
        '--show-tree[Display a file system tree summary]'
        '--no-show-tree[Display a file system tree summary]'
        '--release[Perform release build]'
        '--debug[Perform debug build]'
        '--export-project[Export project sources]'
        '--no-export-project[Export project sources]'
        '--ios[Export iOS .ipa]'
        '--no-ios[Export iOS .ipa]'
        '--ios-sim[Export iOS simulator .app.zip]'
        '--no-ios-sim[Export iOS simulator .app.zip]'
        '--android[Export Android .apk]'
        '--no-android[Export Android .apk]'
        '--nested[Output folders to variant sub-folders]'
        '--no-nested[Output folders to variant sub-folders]'
        '--sdk-path[SDK path for export build]:sdk dir:'
        '--scheme-name[Project scheme name to export]:scheme:'
        '*--arch[Destination architectures for native libraries]:arch:{__skip_complete "${___arch[@]}"}'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_devices() {
    local -i ret=1
    local -ar arg_specs=(
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_test() {
    local -i ret=1
    local -ar arg_specs=(
        '(-o --output)'{-o,--output}'[Send output to the given file (stdout\: -)]:path:'
        '(-E --message-errout)'{-E,--message-errout}'[Emit messages to the output rather than stderr]'
        '(-v --verbose)'{-v,--verbose}'[Whether to display verbose messages]'
        '(-q --quiet)'{-q,--quiet}'[Quiet mode\: suppress output]'
        '(-J --json)'{-J,--json}'[Emit output as formatted JSON]'
        '(-j --json-compact)'{-j,--json-compact}'[Emit output as compact JSON]'
        '(-M --message-plain)'{-M,--message-plain}'[Show console messages as plain text rather than JSON]'
        '--log-file[Send log output to the file]:path:'
        '(-A --json-array)'{-A,--json-array}'[Wrap and delimit JSON output as an array]'
        '--plain[Show no colors or progress animations]'
        '--no-plain[Show no colors or progress animations]'
        '--test[Run the project tests]'
        '--no-test[Run the project tests]'
        '*--filter[Test filter(s) to run]:Test.testFun:'
        '--project[Project folder]:dir:'
        '--xunit[Path to xunit test report]:xunit.xml:'
        '--junit[Path to junit test report]:folder:'
        '--max-column-length[Maximum table column length]:n:'
        '--xcodebuild[Xcode command path]:path:'
        '--swift[Swift command path]:path:'
        '--gradle[Gradle command path]:path:'
        '--adb[ADB command path]:path:'
        '--emulator[Android emulator path]:path:'
        '--sdkmanager[Android SDK Manager command path]:path:'
        '--avdmanager[Android AVD Manager command path]:path:'
        '--java-home[Path to JAVA_HOME]:path:'
        '(-c --configuration)'{-c,--configuration}'[Configuration debug/release]:c:'
        '--summary-file[Output summary table]:path:'
        '--android-serial[Android device or emulator serial for instrumented tests (omit for local Robolectric testing)]:ANDROID_SERIAL:'
        '(-h --help)'{-h,--help}'[Show help information.]'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

_skip_help() {
    local -i ret=1
    local -ar arg_specs=(
        '*:subcommands:'
    )
    _arguments -w -s -S : "${arg_specs[@]}" && ret=0

    return "${ret}"
}

if [[ "${funcstack[1]}" = _skip ]]; then
    _skip "${@}"
else
    compdef _skip skip
fi
