Skip to content

Conversation

@schrockn
Copy link
Member

Extends the erk current command with --json flag to output worktree information in machine-readable format. Enables automation tools and scripts to reliably extract current worktree details (name, path, is_root status) with strict schema validation.

Files Changed

Added

  • src/erk/cli/json_schemas.py CurrentCommandResponse class

Modified

  • src/erk/cli/commands/current.py - Added --json flag and JSON response handling
  • tests/commands/display/test_current.py - Added 3 new JSON output tests

Key Changes

  • New CurrentCommandResponse Pydantic schema (name, path, is_root fields)
  • --json flag routes output through JSON serialization layer
  • Refactored output logic to support both text and JSON formats
  • Full test coverage: worktree JSON, root worktree JSON, and schema validation

Test Results

All 1575 tests passing. CI validation complete.

Copy link
Member Author

schrockn commented Nov 17, 2025

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@schrockn schrockn force-pushed the add-json-support-to-current-25-11-17 branch from a785d0b to e269f48 Compare November 17, 2025 18:24
@schrockn schrockn force-pushed the add-json-format-all-commands-25-11-17 branch from 7e8b970 to 752cf37 Compare November 17, 2025 18:24
Extends the `erk current` command with `--json` flag to output worktree information in machine-readable format. Enables automation tools and scripts to reliably extract current worktree details (name, path, is_root status) with strict schema validation.

## Files Changed

### Added
- `src/erk/cli/json_schemas.py` CurrentCommandResponse class

### Modified
- `src/erk/cli/commands/current.py` - Added --json flag and JSON response handling
- `tests/commands/display/test_current.py` - Added 3 new JSON output tests

## Key Changes

- New `CurrentCommandResponse` Pydantic schema (name, path, is_root fields)
- `--json` flag routes output through JSON serialization layer
- Refactored output logic to support both text and JSON formats
- Full test coverage: worktree JSON, root worktree JSON, and schema validation

## Test Results

All 1575 tests passing. CI validation complete.
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.

2 participants