Skip to content

Merge doubled CLI formatting stacks (output_formatters.py + rich_output.py) behind a presentation-neutral layer #100

Description

@eman

Summary

Deferred follow-up from #95 (comprehensive repo evaluation, batch 6: architecture cleanup).

The CLI currently maintains two large, largely parallel formatting stacks:

  • src/nwp500/cli/output_formatters.py (~1106 lines)
  • src/nwp500/cli/rich_output.py (~982 lines)

Together these total roughly 2100 lines with significant overlap in responsibility (formatting the same device/status/schedule data for different output modes), which increases the maintenance burden whenever a new field or command is added — logic has to be updated/kept-in-sync in two places.

Suggested approach

  • Introduce a presentation-neutral intermediate representation (e.g. structured rows/sections) that both the plain-text and rich-based renderers consume.
  • Migrate formatting logic incrementally so both stacks call into shared data-shaping code, leaving only true rendering-technology differences (colors, tables, plain strings) in each module.
  • Consider whether one of the two stacks can be retired entirely if presentation differences turn out to be minor.

Acceptance criteria

  • Duplicated formatting/data-shaping logic between the two modules is eliminated or minimized.
  • CLI output (both plain and rich modes) is unchanged for existing commands, verified by existing CLI tests.
  • ruff/mypy clean.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions