Skip to content

feat: add --json output flag to all commands (closes #1)#24

Open
chengfei-gh wants to merge 1 commit intoApexOpsStudio:mainfrom
chengfei-gh:feat/json-output-2
Open

feat: add --json output flag to all commands (closes #1)#24
chengfei-gh wants to merge 1 commit intoApexOpsStudio:mainfrom
chengfei-gh:feat/json-output-2

Conversation

@chengfei-gh
Copy link

Feature for #1: Add --json output format

Implementation

Added --json flag to all commands (add, list, done) that outputs valid, parseable JSON.

JSON Output Format

// Success responses
{"status": "ok", "task": {"id": 1, "description": "Buy milk", "done": false}}
{"status": "ok", "tasks": [{...}, {...}]}

// Error responses
{"status": "error", "message": "No tasks found"}

Usage Examples

python task.py add "Buy milk" --json
# {"status": "ok", "task": {"id": 1, "description": "Buy milk", "done": false}}

python task.py list --json
# {"status": "ok", "tasks": [{"id": 1, "description": "Buy milk", "done": false}]}

python task.py done 1 --json
# {"status": "ok", "task": {"id": 1, "description": "Buy milk", "done": true}}

Changes

  • task.py: Added --json flag to main parser and all subcommand parsers
  • commands/add.py: JSON output with new task details
  • commands/list.py: JSON output with all tasks array
  • commands/done.py: JSON output with updated task or error

Acceptance Criteria

  • All commands support --json flag
  • JSON output is valid and parseable
  • Backward compatible (default output unchanged)
  • Consistent {status, ...} envelope format

Payment

Solana wallet: CZkLs4m55JBffoowGUtyfqb5GrymUVxgr9kMTrXKfbJV

Implements ApexOpsStudio#1

Changes:
- Added --json flag to main parser and all subcommands
- add: outputs {status, task} as JSON when --json flag present
- list: outputs {status, tasks[]} as JSON when --json flag present
- done: outputs {status, task} or {status, error} as JSON

JSON output format:
- Success: {"status": "ok", "task": {...}} or {"status": "ok", "tasks": [...]}
- Error: {"status": "error", "message": "..."}

Usage examples:
  python task.py add "Buy milk" --json
  python task.py list --json
  python task.py done 1 --json

All existing tests still pass.
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.

1 participant