feat: replace ad-hoc --json flag with unified --output table|json|yaml#25
Merged
feat: replace ad-hoc --json flag with unified --output table|json|yaml#25
--json flag with unified --output table|json|yaml#25Conversation
…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 Mar 16, 2026
--json flag with unified --output table|json|yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
All CLI list/show commands had a scattered
--jsonboolean 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|yamlemit(data, output_format, table_fn): dispatches to JSON/YAML serialization or a caller-supplied rich table rendererUpdated 8 commands across
courses,categories,sections,users, andmodules—--json: boolremoved,--output: OutputFormat = tableadded; table rendering refactored into local_render_tableclosures passed toemit()pyyamladded as an explicit runtime dependency (was already present transitively)19 new unit tests in
tests/unit/test_output_format.pycoveringemit()behavior for all three formats, unicode preservation, missingtable_fnguard, and help-text assertions for each updated commandUsage
Adding
--outputsupport to a new command is now one import + oneemit()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.