#compdef tpa
# Installed in the system vendor completion directory.
_tpa() {
    local context state state_descr line
    local -a words=( "${words[@]}" )
    local CURRENT=$CURRENT
    typeset -A opt_args
    local -a commands
    commands=(
        'init:Initialize a package tree'
        'build:Build a Debian package'
        'check:Check package-tree metadata without modification'
        'compose:Build a new repository directly from metadata-only JSON definitions'
        'parse:Read package metadata'
        'pack:Build an APT repository'
        'publish:Publish an already-signed repository to an explicit TPA.run SSH destination'
        'stage:Create, upload, inspect or cancel a private repository-scoped CAS stage'
        'sign:Finalize a staged release with owner-side signing and atomic SSH-CAS publication'
        'inspect:Inspect an existing repository'
        'capabilities:Print machine-readable TPA capabilities'
        'completion:Print shell completion for bash, zsh, or fish'
        'verify:Verify an existing repository'
        'unlist:Remove a package from repository metadata'
        'delete:Unlist and permanently remove a package artifact'
        'json:Build from JSON configuration'
        'schema:Print the configuration schema'
        'version:Print the TPA version'
        'register:Register with a TPA.run account server (pinned customer SSH)'
        'login:Log in to a TPA.run account server (pinned customer SSH)'
        'help:Show help'
    )
    if (( CURRENT == 2 )); then
        _describe 'command' commands
        _arguments '(-h --help)'{-h,--help}'[Show help]' '(-version --version)'{-version,--version}'[Show version]'
        return
    fi
    words=( "${words[@]:1}" )
    (( CURRENT-- ))
    case $words[1] in
        init)
            _arguments -s '(-name --name)'{-name,--name}'[Package name]:value:' '(-ver --ver)'{-ver,--ver}'[Package version]:value:' '(-arch --arch)'{-arch,--arch}'[Package architecture]:value:(all amd64 arm64 armhf i386 riscv64)' '(-maintainer --maintainer)'{-maintainer,--maintainer}'[Maintainer]:value:' '(-desc --desc)'{-desc,--desc}'[Description]:value:' '(-depends --depends)'{-depends,--depends}'[Dependencies]:value:' '(-pre-depends --pre-depends)'{-pre-depends,--pre-depends}'[Pre-dependencies]:value:' '(-recommends --recommends)'{-recommends,--recommends}'[Recommendations]:value:' '(-suggests --suggests)'{-suggests,--suggests}'[Suggestions]:value:' '(-provides --provides)'{-provides,--provides}'[Provided packages]:value:' '(-conflicts --conflicts)'{-conflicts,--conflicts}'[Conflicts]:value:' '(-breaks --breaks)'{-breaks,--breaks}'[Breaks]:value:' '(-replaces --replaces)'{-replaces,--replaces}'[Replacements]:value:' '(-homepage --homepage)'{-homepage,--homepage}'[Homepage]:value:' '(-section --section)'{-section,--section}'[Section]:value:' '(-priority --priority)'{-priority,--priority}'[Priority]:value:' '(-built-using --built-using)'{-built-using,--built-using}'[Built using]:value:' '(-essential --essential)'{-essential,--essential}'[Essential package]:value:(yes no)' '(-multi-arch --multi-arch)'{-multi-arch,--multi-arch}'[Multi-Arch policy]:value:(no same foreign allowed)' '(-preinst --preinst)'{-preinst,--preinst}'[Pre-install script body]:value:' '(-postinst --postinst)'{-postinst,--postinst}'[Post-install script body]:value:' '(-prerm --prerm)'{-prerm,--prerm}'[Pre-removal script body]:value:' '(-postrm --postrm)'{-postrm,--postrm}'[Post-removal script body]:value:' '(-out --out)'{-out,--out}'[Package output directory]:value:_files -/' '(-no-provenance --no-provenance)'{-no-provenance,--no-provenance}'[Disable automatic provenance]' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        build)
            _arguments -s '(-in --in)'{-in,--in}'[Package tree]:value:_files -/' '(-out --out)'{-out,--out}'[Output archive or directory]:value:_files' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        check)
            _arguments -s '(-in --in)'{-in,--in}'[Package tree]:value:_files -/' '(-json --json)'{-json,--json}'[JSON diagnostics]' '(-h --help)'{-h,--help}'[Show help]' '1:path or URL:_files'
            ;;
        compose)
            _arguments -s '(-in --in)'{-in,--in}'[JSON, JSONL or directory of definitions]:value:_files' '(-out --out)'{-out,--out}'[New local repository]:value:_files -/' '(-workers --workers)'{-workers,--workers}'[Build worker count]:value:' '(-memory-mib --memory-mib)'{-memory-mib,--memory-mib}'[Worker scratch budget in MiB]:value:' '(-epoch --epoch)'{-epoch,--epoch}'[Reproducible Unix timestamp]:value:' '(-gpg --gpg)'{-gpg,--gpg}'[Signing identity]:value:' '(-origin --origin)'{-origin,--origin}'[Repository origin]:value:' '(-label --label)'{-label,--label}'[Repository label]:value:' '(-suite --suite)'{-suite,--suite}'[Suite]:value:' '(-codename --codename)'{-codename,--codename}'[Codename]:value:' '(-components --components)'{-components,--components}'[Component]:value:' '(-repo-description --repo-description)'{-repo-description,--repo-description}'[Repository description]:value:' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        parse)
            _arguments -s '(-in --in)'{-in,--in}'[Debian archive]:value:_files' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        pack)
            _arguments -s '(-in --in)'{-in,--in}'[Package input directory]:value:_files -/' '(-out --out)'{-out,--out}'[Repository output]:value:_files -/' '(-output --output)'{-output,--output}'[Output path or SSH destination]:value:_files -/' '(-atomic-publish --atomic-publish)'{-atomic-publish,--atomic-publish}'[Atomic local destination]:value:_files -/' '(-empty --empty)'{-empty,--empty}'[Initialize an empty repository]' '(-architectures --architectures)'{-architectures,--architectures}'[Comma-separated architectures]:value:' '(-origin --origin)'{-origin,--origin}'[Repository origin]:value:' '(-label --label)'{-label,--label}'[Repository label]:value:' '(-suite --suite)'{-suite,--suite}'[APT suite]:value:' '(-codename --codename)'{-codename,--codename}'[Distribution codename]:value:' '(-components --components)'{-components,--components}'[Repository component]:value:' '(-repo-description --repo-description)'{-repo-description,--repo-description}'[Repository description]:value:' '(-gpg --gpg)'{-gpg,--gpg}'[Signing key fingerprint]:value:' '(-workers --workers)'{-workers,--workers}'[Worker count]:value:' '(-ssh-config --ssh-config)'{-ssh-config,--ssh-config}'[OpenSSH configuration]:value:_files' '(-generation-manifest --generation-manifest)'{-generation-manifest,--generation-manifest}'[Generation inventory output]:value:_files' '(-repository-id --repository-id)'{-repository-id,--repository-id}'[Repository identity]:value:' '(-generation-id --generation-id)'{-generation-id,--generation-id}'[Generation identity]:value:' '(-parent-generation --parent-generation)'{-parent-generation,--parent-generation}'[Expected parent generation]:value:' '(-h --help)'{-h,--help}'[Show help]' '1:path or URL:_files'
            ;;
        publish)
            _arguments -s '(-json --json)'{-json,--json}'[Publish result and transfer counters as JSON]:value:' '(-in --in)'{-in,--in}'[Finished signed repository]:value:_files -/' '(-out --out)'{-out,--out}'[Explicit TPA.run SSH destination]:value:' '(-output --output)'{-output,--output}'[Explicit TPA.run SSH destination]:value:' '(-ssh-config --ssh-config)'{-ssh-config,--ssh-config}'[OpenSSH config]:value:_files' '(-keyring --keyring)'{-keyring,--keyring}'[Owner public key]:value:_files' '(-fingerprint --fingerprint)'{-fingerprint,--fingerprint}'[Expected owner signer]:value:' '(-generation-id --generation-id)'{-generation-id,--generation-id}'[Generation identity]:value:' '(-parent-generation --parent-generation)'{-parent-generation,--parent-generation}'[Expected parent]:value:' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        stage)
            _arguments -s '(-output --output)'{-output,--output}'[Repository SSH-CAS destination]:value:' '(-stage --stage)'{-stage,--stage}'[Persistent 32-hex stage identity]:value:' '(-manifest --manifest)'{-manifest,--manifest}'[Qualified artifact manifest]:value:_files' '(-in --in)'{-in,--in}'[Already-built Debian archive]:value:_files' '(-ssh-config --ssh-config)'{-ssh-config,--ssh-config}'[Pinned SSH configuration]:value:_files' '(-parent-generation --parent-generation)'{-parent-generation,--parent-generation}'[Pinned base or auto]:value:' '(-json --json)'{-json,--json}'[JSON stage result]' '(-h --help)'{-h,--help}'[Show help]' '1:operation:(create upload inspect cancel)'
            ;;
        sign)
            _arguments -s '(-output --output)'{-output,--output}'[Repository SSH-CAS destination]:value:' '(-stage --stage)'{-stage,--stage}'[Persistent release stage]:value:' '(-manifest --manifest)'{-manifest,--manifest}'[Approved artifact manifest]:value:_files' '(-gpg --gpg)'{-gpg,--gpg}'[Owner signing identity]:value:' '(-keyring --keyring)'{-keyring,--keyring}'[Owner public trust]:value:_files' '(-fingerprint --fingerprint)'{-fingerprint,--fingerprint}'[Expected signer]:value:' '(-ssh-config --ssh-config)'{-ssh-config,--ssh-config}'[Pinned SSH configuration]:value:_files' '(-origin --origin)'{-origin,--origin}'[Existing APT origin]:value:' '(-label --label)'{-label,--label}'[Existing APT label]:value:' '(-repo-description --repo-description)'{-repo-description,--repo-description}'[APT repository description]:value:' '(-json --json)'{-json,--json}'[JSON receipt]' '(-h --help)'{-h,--help}'[Show help]' '1:repository SSH URL:'
            ;;
        inspect)
            _arguments -s '(-in --in)'{-in,--in}'[Repository path or URL]:value:_files -/' '(-codename --codename)'{-codename,--codename}'[Distribution codename]:value:' '(-package --package)'{-package,--package}'[Exact package name]:value:' '(-ver --ver)'{-ver,--ver}'[Exact package version]:value:' '(-arch --arch)'{-arch,--arch}'[Exact architecture]:value:(all amd64 arm64 armhf i386 riscv64)' '(-json --json)'{-json,--json}'[JSON output]' '(-keyring --keyring)'{-keyring,--keyring}'[Public signing key]:value:_files' '(-fingerprint --fingerprint)'{-fingerprint,--fingerprint}'[Expected signer fingerprint]:value:' '(-require-signed --require-signed)'{-require-signed,--require-signed}'[Require signed metadata]' '(-h --help)'{-h,--help}'[Show help]' '1:path or URL:_files'
            ;;
        capabilities)
            _arguments -s '(-h --help)'{-h,--help}'[Show help]'
            ;;
        completion)
            _arguments -s '(-h --help)'{-h,--help}'[Show help]' '1:shell:(bash zsh fish)'
            ;;
        verify)
            _arguments -s '(-in --in)'{-in,--in}'[Repository path or URL]:value:_files -/' '(-codename --codename)'{-codename,--codename}'[Distribution codename]:value:' '(-json --json)'{-json,--json}'[JSON output]' '(-keyring --keyring)'{-keyring,--keyring}'[Public signing key]:value:_files' '(-fingerprint --fingerprint)'{-fingerprint,--fingerprint}'[Expected signer fingerprint]:value:' '(-require-signed --require-signed)'{-require-signed,--require-signed}'[Require signed metadata]' '(-h --help)'{-h,--help}'[Show help]' '1:path or URL:_files'
            ;;
        unlist)
            _arguments -s '(-in --in)'{-in,--in}'[Repository directory]:value:_files -/' '(-package --package)'{-package,--package}'[Exact package name]:value:' '(-ver --ver)'{-ver,--ver}'[Exact package version]:value:' '(-arch --arch)'{-arch,--arch}'[Exact architecture]:value:(all amd64 arm64 armhf i386 riscv64)' '(-gpg --gpg)'{-gpg,--gpg}'[Signing key fingerprint]:value:' '(-codename --codename)'{-codename,--codename}'[Distribution codename]:value:' '(-components --components)'{-components,--components}'[Repository component]:value:' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        delete)
            _arguments -s '(-in --in)'{-in,--in}'[Repository directory]:value:_files -/' '(-package --package)'{-package,--package}'[Exact package name]:value:' '(-ver --ver)'{-ver,--ver}'[Exact package version]:value:' '(-arch --arch)'{-arch,--arch}'[Exact architecture]:value:(all amd64 arm64 armhf i386 riscv64)' '(-gpg --gpg)'{-gpg,--gpg}'[Signing key fingerprint]:value:' '(-codename --codename)'{-codename,--codename}'[Distribution codename]:value:' '(-components --components)'{-components,--components}'[Repository component]:value:' '(-yes --yes)'{-yes,--yes}'[Confirm deletion]' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        json)
            _arguments -s '(-no-provenance --no-provenance)'{-no-provenance,--no-provenance}'[Disable automatic provenance]' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        schema)
            _arguments -s '(-h --help)'{-h,--help}'[Show help]'
            ;;
        version)
            _arguments -s '(-h --help)'{-h,--help}'[Show help]'
            ;;
        register)
            _arguments -s '(-address --address)'{-address,--address}'[Explicit customer SSH host:port]:value:' '(-known-hosts --known-hosts)'{-known-hosts,--known-hosts}'[Pinned SSH host keys]:value:_files' '(-identity --identity)'{-identity,--identity}'[Client SSH identity]:value:_files' '(-server --server)'{-server,--server}'[Expected HTTPS account origin]:value:' '(-confirm --confirm)'{-confirm,--confirm}'[Confirm own browser enrollment]' '(-confirmation-file --confirmation-file)'{-confirmation-file,--confirmation-file}'[Private confirmation file]:value:_files' '(-h --help)'{-h,--help}'[Show help]'
            ;;
        login)
            _arguments -s '(-address --address)'{-address,--address}'[Explicit customer SSH host:port]:value:' '(-known-hosts --known-hosts)'{-known-hosts,--known-hosts}'[Pinned SSH host keys]:value:_files' '(-identity --identity)'{-identity,--identity}'[Client SSH identity]:value:_files' '(-server --server)'{-server,--server}'[Expected HTTPS account origin]:value:' '(-h --help)'{-h,--help}'[Show help]'
            ;;
    esac
}
_tpa "$@"
