Deferred from local repository review cleanup.
Problem
main.go currently combines flag parsing, validation, timestamp-bound selection, statement classification, Spanner client setup, execution mode routing, output selection, tracing, and gRPC logging. This makes CLI-routing behavior hard to unit-test without reaching into _main, global os.Args, os.Stdout, and live Spanner paths.
There are also parallel mode switches for normal jq/json/yaml output, CSV output, and partition-query checks. That makes it easy for flags to be accepted on paths where they are later ignored.
Proposed work
Extract small, testable layers without changing user-visible behavior:
cmd/execspansql or a minimal root main.go for process exit handling.
- An app runner such as
Run(ctx, Config, IO, ClientFactory) error.
- A Spanner execution layer for statement classification, timestamp-bound selection, transaction mode, query options, and partition-query checks.
- Output sinks for jq JSON/YAML, CSV, and future JSONL/stats side channels.
- Observability setup for tracing and gRPC logging.
This should be incremental. First extract seams that let issue #63 cover routing behavior, then collapse duplicated mode dispatch.
Acceptance criteria
- CLI behavior remains compatible except for separately documented validation fixes.
- Unit tests cover DML classification, timestamp-bound selection, help/flag validation, tracing setup, and log-grpc mode selection without requiring live Spanner.
- Integration tests continue to cover actual emulator-backed execution paths.
- Adding a new output format requires changing one output-routing area rather than every execution-mode switch.
Deferred from local repository review cleanup.
Problem
main.gocurrently combines flag parsing, validation, timestamp-bound selection, statement classification, Spanner client setup, execution mode routing, output selection, tracing, and gRPC logging. This makes CLI-routing behavior hard to unit-test without reaching into_main, globalos.Args,os.Stdout, and live Spanner paths.There are also parallel mode switches for normal jq/json/yaml output, CSV output, and partition-query checks. That makes it easy for flags to be accepted on paths where they are later ignored.
Proposed work
Extract small, testable layers without changing user-visible behavior:
cmd/execspansqlor a minimal rootmain.gofor process exit handling.Run(ctx, Config, IO, ClientFactory) error.This should be incremental. First extract seams that let issue #63 cover routing behavior, then collapse duplicated mode dispatch.
Acceptance criteria