Skip to content

rust-cli: standalone cocoindex CLI for Rust projects #2279

Description

@tomz-alt

Part of #2273. Spec: dev/plans/rust-cli.md (lands with the first PR).

One Rust binary with the same commands as the Python CLI. Pipeline logic is compiled into the
user's binary, so the CLI works like cargo run: build the crate, run the user's binary,
pass the subcommand through over versioned JSON-lines on stdio. ls --db / show skip the
build and read the state db directly via core::inspect.

  • SDK registration: #[cocoindex::app] + #[cocoindex::lifespan] via linkme (same
    mechanism as #[cocoindex::function]), #[cocoindex::main] dispatch,
    Environment::from_registered(), EnvironmentBuilder::on_shutdown — the CLI path and
    the user's own main initialize environments through the identical lifespans
    (Rust analogue of @coco.lifespan + import)
  • SDK: cli::try_dispatch() handling __coco ls|update|drop + protocol events
    (start / progress / preview / done / error), exit codes, version handshake
  • new crate rust/cli/: ls [--db], show, update [-L] [--full-reprocess] [--preview] [--reset], drop [--db-only], init scaffold, --env-file
  • migrate examples/rust/text_embedding as the validating example (cocoindex update,
    -L, --preview, show, drop all work; cargo run -- query untouched)

Phase 2 (follow-up issue once this lands): ship the binary in the Python wheels (ruff-style)
and replace the click front-end with a thin python -m cocoindex protocol child — one CLI
for both SDKs.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions