feat(cli): add a json output and tests

This commit is contained in:
2025-11-21 12:59:36 +01:00
parent 30a2e88685
commit 7fca1f78dc
18 changed files with 829 additions and 95 deletions

View File

@@ -251,6 +251,29 @@ Goyco includes a comprehensive CLI for administration:
./bin/goyco prune all # Hard delete all users and posts
```
### JSON Output
All CLI commands support JSON output for easier parsing and integration with scripts. Use the `--json` flag to enable structured JSON output:
```bash
# Get JSON output
./bin/goyco --json user list
./bin/goyco --json post list
./bin/goyco --json status
# Example: Parse JSON output with jq
./bin/goyco --json user list | jq '.users[0].username'
./bin/goyco --json status | jq '.status'
```
**Note for destructive operations**: When using `--json` with `prune` commands, you must also use the `--yes` flag to skip interactive confirmation prompts:
```bash
./bin/goyco --json prune posts --yes
./bin/goyco --json prune users --yes --with-posts
./bin/goyco --json prune all --yes
```
## Development
### Get the sources
@@ -382,7 +405,7 @@ make fuzz-tests
# Format code
make format
# Run linter
# Run linter
make lint
```