Skip to content

feat: replace ad-hoc --json flag with unified --output table|json|yaml#25

Merged
erseco merged 2 commits intomainfrom
copilot/create-roadmap-task
Mar 16, 2026
Merged

feat: replace ad-hoc --json flag with unified --output table|json|yaml#25
erseco merged 2 commits intomainfrom
copilot/create-roadmap-task

Conversation

Copy link
Contributor

Copilot AI commented Mar 16, 2026

All CLI list/show commands had a scattered --json boolean with no YAML support and no shared output contract, making scripting inconsistent and blocking future field-filtering work.

Changes

  • New src/py_moodle/cli/output.py — centralized output contract:

    • OutputFormat(str, Enum): table | json | yaml
    • emit(data, output_format, table_fn): dispatches to JSON/YAML serialization or a caller-supplied rich table renderer
  • Updated 8 commands across courses, categories, sections, users, and modules--json: bool removed, --output: OutputFormat = table added; table rendering refactored into local _render_table closures passed to emit()

  • pyyaml added as an explicit runtime dependency (was already present transitively)

  • 19 new unit tests in tests/unit/test_output_format.py covering emit() behavior for all three formats, unicode preservation, missing table_fn guard, and help-text assertions for each updated command

Usage

py-moodle courses list                   # table (default, unchanged)
py-moodle courses list --output json     # replaces --json
py-moodle courses list --output yaml     # new

Adding --output support to a new command is now one import + one emit() call.


📍 Connect Copilot coding agent with Jira, Azure Boards or Linear to delegate work to Copilot in one click without leaving your project management tool.

…Subtask 4

Co-authored-by: erseco <1876752+erseco@users.noreply.github.com>
Copilot AI changed the title [WIP] Add roadmap task to project feat: replace ad-hoc --json flag with unified --output table|json|yaml Mar 16, 2026
Copilot AI requested a review from erseco March 16, 2026 14:53
@erseco erseco marked this pull request as ready for review March 16, 2026 15:36
@erseco erseco merged commit 34ac24a into main Mar 16, 2026
13 checks passed
@erseco erseco deleted the copilot/create-roadmap-task branch March 16, 2026 15:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants