-
Notifications
You must be signed in to change notification settings - Fork 38
feat(list): add --json flag with connect/disconnect timestamps #294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Track when sessions were last connected and disconnected. Add --json
flag to output all session data as JSON for scripting.
Example:
shpool list --json | jq '.sessions | sort_by([
({"Disconnected": 0, "Attached": 1}[.status]),
(if .status == "Attached" then .connected_at_unix_ms else .disconnected_at_unix_ms end)
])'
Default tabular output unchanged.
ethanpailes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! just a few bits of feedback and then we should be ready to merge.
I'll also create a bug as a reminder to drop the STARTED_AT column from the normal list output before 1.0. I rather doubt people care about that most of the time, and now that there is a better way to deal with the data we should probably clean that up the next time we do a compatibility break.
- Rename connected_at -> last_connected_at, disconnected_at -> last_disconnected_at - Combine timestamps into SessionLifecycleTimestamps behind single Mutex - Update help text to "Output as JSON, includes extra fields"
|
Made requested changes:
Repeated tests with new changes |
|
Sorry to ask for more changes on a second round, but I just realized the change itself has no new tests. Do you mind adding a new test to sanity check in shpool/tests/list.rs. It doesn't have to be fancy, just lauching a sub-process and grepping the output for one of the new fields and maybe using |
Adds
--jsonflag toshpool listto expose session data including when sessions were last connected/disconnected, making it easier to identify recently-used sessions.Closes #292
Supersedes #293, which added optional columns to the tabular output. Per maintainer feedback, pivoted to a single
--jsonflag that outputs all session data as JSON, allowing users to filter/format withjq.New
--jsonCLI flag:Behavior:
shpool listbehaves exactly as before.name,started_at_unix_ms,connected_at_unix_ms,disconnected_at_unix_ms,statusnulluntil the relevant event occurs.Testing: