Feature/cli status#1811
Open
jeregon1 wants to merge 6 commits into
Open
Conversation
- Extract pure snapshot logic to app/utils/cliStatus.js - Add --json/-j option to status command - Wire --json flag through both instance paths in main.js - Detect paused state in status output - Delete snapshot file on app quit - Add 24 unit tests for all three exported functions - Update CHANGELOG
…n fields to JSON output - Replace app.quit() with app.exit(0) in status handlers to bypass before-quit handler (globalShortcut not ready) - Add time_to_*_human and long_break_enabled fields to JSON output - Rename time_to_* fields to time_to_*_ms for clarity - Update printJsonSnapshotAsText to use new field names - Update tests to match new JSON shape
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a stretchly status CLI command intended to expose the current break state without opening the GUI, with optional --json / -j output for status bar/script integration. It implements a snapshot-based approach by having the running instance write a JSON snapshot to the user data directory, which subsequent invocations can read.
Changes:
- Added CLI parsing/support for a new
statuscommand (including--json/-j). - Added snapshot generation utilities (
app/utils/cliStatus.js) and a new test suite covering status formatting/snapshot building. - Updated documentation (README/CHANGELOG) to mention the new CLI behavior.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| test/commands.js | Adds coverage ensuring --status is recognized and not forwarded to the main instance. |
| test/cliStatus.js | Adds tests for duration formatting and status snapshot construction in text and JSON modes. |
| README.md | Documents the new status CLI usage. |
| CHANGELOG.md | Notes the new CLI status command and JSON flag. |
| app/utils/commands.js | Registers the status command and --json option; adds examples; tweaks parsing for --status. |
| app/utils/cliStatus.js | Introduces snapshot building + long-break time computation helpers. |
| app/main.js | Writes status snapshot periodically (via tray update path) and adds logic to print status from snapshot / headless run. |
Comment on lines
27
to
31
| ======= | ||
| - `stretchly status` command to show current break state from CLI | ||
| - `stretchly status --json` flag for machine-readable JSON output | ||
| >>>>>>> f254297a (feat: implement stretchly status command with --json flag) | ||
| - advanced option for Break Health Mode |
| When a Stretchly instance is running, the `stretchly` command can be use to interact with it from the command line. | ||
|
|
||
| Type `stretchly help` to get a list of all commands and options available as well as some examples. | ||
| Type `stretchly --status` to see either active break details (type + time remaining) or, when no break is active, time to next break and next long break. |
Comment on lines
+1402
to
1406
| writeCliStatusSnapshot() | ||
|
|
||
| if (!appIcon && !settings.get('showTrayIcon')) { | ||
| return | ||
| } |
Comment on lines
+380
to
+384
| const startupCommand = new Command(commandLineArguments, app.getVersion(), false) | ||
| if (startupCommand.command === 'status') { | ||
| printCliStatusAndQuit(startupCommand.options && startupCommand.options.json) | ||
| return | ||
| } |
Comment on lines
+67
to
+73
| if (json) { | ||
| return { | ||
| status: 'active_break', | ||
| break_type: reference === 'finishMicrobreak' ? 'mini' : 'long', | ||
| time_to_break_end_ms: breakPlanner.scheduler.timeLeft, | ||
| time_to_break_end_human: formatCliDuration(breakPlanner.scheduler.timeLeft) | ||
| } |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue: #1628
Requirements
nodeversion specified inpackage.jsonwas used (v22+).npm run lintreports no offenses.npm run testis error-free (24 new tests pass).Description of the Change
Adds a
stretchly statusCLI command that shows the current break state without opening the GUI. Supports both human-readable text output and--json/-jfor machine parsing (integration with polybar, i3status, etc.).States detected:
no_active_break— shows time remaining until the next mini and long breakactive_break— shows break type (mini/long) and time until it endspaused— shows that breaks are pausedSnapshot-based architecture: The running instance periodically writes a JSON snapshot file. Any second instance reads this file to display status, avoiding IPC complexity and keeping the first instance unmodified.
Verification Process
npm run lint— cleannpm run test— 24 new tests + 32 existing = 56 passednpm run pack— builds successfully on Windows