Skip to content

feat: #1 add --json output format for all commands#58

Open
tarai-dl wants to merge 1 commit intoApexOpsStudio:mainfrom
tarai-dl:az/add-json-output-format
Open

feat: #1 add --json output format for all commands#58
tarai-dl wants to merge 1 commit intoApexOpsStudio:mainfrom
tarai-dl:az/add-json-output-format

Conversation

@tarai-dl
Copy link
Copy Markdown

What does this PR do?

Fixes #1 — Adds --json flag to output valid JSON for scripting and automation.

Changes

  • Added --json as a global flag on the main parser
  • add --json — outputs single task object: {"id": 1, "description": "...", "done": false}
  • list --json — outputs tasks array: [{...}, {...}] (empty array [] if no tasks)
  • done --json — outputs updated task object with done: true
  • All existing text output behavior preserved when --json is not used

Usage

python3 task.py --json add "buy groceries"
# {"id": 1, "description": "buy groceries", "done": false}

python3 task.py --json list
# [{"id": 1, "description": "buy groceries", "done": false}]

python3 task.py --json done 1
# {"id": 1, "description": "buy groceries", "done": true}

Tests

  • 7 tests all pass
  • New tests: test_add_json_output, test_list_json_output, test_list_json_empty, test_done_json_output, test_cli_json_flag

Fixes #1

- Add --json flag to global parser (available for all subcommands)
- add command: outputs single task object as JSON
- list command: outputs tasks array as JSON (empty array if no tasks)
- done command: outputs updated task object as JSON
- All existing text output behavior preserved when --json not used
- Added 5 new tests for JSON output (add, list, list empty, done, CLI)
- All 7 tests pass

Fixes ApexOpsStudio#1
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.

Add --json output format

1 participant