Skip to content

feat: add --json output flag to all commands (Closes #1)#54

Open
alexanderxfgl-bit wants to merge 4 commits intoApexOpsStudio:mainfrom
alexanderxfgl-bit:feat/json-output-flag
Open

feat: add --json output flag to all commands (Closes #1)#54
alexanderxfgl-bit wants to merge 4 commits intoApexOpsStudio:mainfrom
alexanderxfgl-bit:feat/json-output-flag

Conversation

@alexanderxfgl-bit
Copy link
Copy Markdown

What

Adds --json flag to all CLI commands (add, list, done) for structured output.

Changes

  • task.py: Add global --json argument, pass json_output to commands
  • commands/add.py: Return task dict as JSON when flag set
  • commands/list.py: Return tasks array as JSON when flag set
  • commands/done.py: Return task dict or error object as JSON when flag set
  • test_task.py: 6 new tests covering JSON output for all commands + edge cases

Testing

8 passed in 0.03s

Example

$ python task.py add "Build API" --json
{"id": 1, "description": "Build API", "done": false}

$ python task.py list --json
[{"id": 1, "description": "Build API", "done": false}]

$ python task.py done 1 --json
{"id": 1, "description": "Build API", "done": true}

Closes #1

- Add --json flag to add, list, and done commands
- JSON output returns valid parseable JSON objects/arrays
- Error states return JSON with 'error' key
- Add 6 new tests covering JSON output scenarios
- Closes ApexOpsStudio#1
- load_config() now creates default config.yaml if missing
- Creates parent directories as needed
- Add 3 tests for config handling
- All 11 tests pass

Closes ApexOpsStudio#2
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