Skip to content

Tracer: fafycat cat list end-to-end #27

@davidchris

Description

@davidchris

Parent

#26

What to build

The first vertical slice of the read-only query CLI. Adds a single subcommand fafycat cat list that returns all categories as JSON. Establishes the patterns every later slice will reuse:

  • Nested argparse subparsers (cat namespace).
  • JSON-only stdout output with indent=2.
  • Error contract: {"error": "..."} to stdout with non-zero exit; argparse usage to stderr with exit 2.
  • Logging suppressed below ERROR for query handlers.
  • Subprocess-based integration tests against a temporary database.
  • Reuse of CategoryService.get_categories from the existing service kernel — no new business logic.
  • Reuse of --data-dir and FAFYCAT_DATA_DIR resolution via the existing _apply_data_dir_override helper.

A small shared output helper module is introduced here so later slices share the same JSON / exit-code framing.

Acceptance criteria

  • Running fafycat cat list returns a JSON array of category objects on stdout, exit 0.
  • Running fafycat cat list --include-inactive includes inactive categories in the result.
  • Running fafycat cat list --help exits 0 and prints usage including at least one example invocation.
  • Running fafycat cat --help lists the list subcommand.
  • Stdout is valid JSON parseable by json.loads.
  • Stdout is indent=2 formatted.
  • Stderr is empty on the happy path.
  • Argparse errors (e.g. unknown flag) exit 2 with usage on stderr.
  • Runtime errors (e.g. missing DB) emit {"error": "..."} to stdout and exit 1.
  • Existing fafycat serve, fafycat import, fafycat init commands continue to work unchanged.
  • Tests are written before the implementation (red-green TDD).
  • Subprocess integration tests cover happy path, --include-inactive, missing-DB error path.
  • No assertions on log output, internal call order, or private attributes.

Blocked by

None - can start immediately.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions