---
name: Athena CLI plan
overview: Add a built-in CLI entrypoint to athena_rs so inline pipeline definitions can be run from the same binary without disrupting the existing API server behavior.
todos:
  - id: cli-entrypoint
    content: Introduce clap parsing and shared AppState/bootstrap helpers in src/main.rs before branching to CLI/server
    status: completed
  - id: pipeline-runner
    content: Add src/cli.rs with pipeline subcommand parsing, JSON ingestion, and run_pipeline invocation
    status: completed
  - id: cli-docs
    content: Document the new pipeline CLI usage plus Cargo dependency changes in README.md
    status: completed
  - id: todo-1771189552052-2adw74uya
    content: add cli command for just invoking the --version, -v or when you just call without any args also fallback ot version
    status: completed
  - id: todo-1771189586086-9ycwsn80w
    content: add cli command for managing the clients and a client file, where you can set a default via the cli, add clients, or remove them
    status: completed
  - id: todo-1771189615737-y2rvszqlc
    content: add cli command for interacting with the athena-db.com/gateway api completely thru cli for fetch only for now, also re-using the same clients
    status: completed
  - id: todo-1771189655125-yxb9qxgdx
    content: "Add cli command for 'diag` that checks what os is running etc, "
    status: completed
isProject: false
---

1. Update [src/main.rs](src/main.rs) to parse `clap` arguments, build the shared `AppState` + pipeline registry, and either launch the existing Actix server (default) or hand control to the new pipeline CLI runner when `pipeline` is selected. Factor the initialization steps (config loading, cache/client/registry creation) into helper functions so both execution paths reuse the same setup logic.
2. Add a new helper module (e.g., [src/cli.rs](src/cli.rs)) that defines the CLI schema (`pipeline run --client <CLIENT> --payload-json <JSON> | --payload-file <PATH>` plus optional `--config`/`--pipelines`) and, when executed, builds an `actix_web::test::TestRequest` with the requested headers, wraps the shared `AppState` in `Data`, invokes [src/api/pipelines/mod.rs::run_pipeline] asynchronously, and prints the resulting JSON to stdout (handling failures by emitting the status message and non-success body).
3. Extend [Cargo.toml](Cargo.toml) with `clap` under `[dependencies]` (derive feature) and call out the CLI workflow in [README.md](README.md) so users know how to run inline pipeline payloads via `cargo run -- pipeline run ...`.
