Skip to content

[CLI] Add --output flag to inv list for machine-readable output#4745

Open
OmarAshour02 wants to merge 1 commit into
restatedev:mainfrom
OmarAshour02:cli/output-flag
Open

[CLI] Add --output flag to inv list for machine-readable output#4745
OmarAshour02 wants to merge 1 commit into
restatedev:mainfrom
OmarAshour02:cli/output-flag

Conversation

@OmarAshour02
Copy link
Copy Markdown

@OmarAshour02 OmarAshour02 commented May 15, 2026

Summary

Closes #3872

  • Adds a global --output flag (human | table | json | jsonl) to restate inv list
  • human is unchanged (existing pretty output with colors and icons)
  • table emits plain columns suitable for awk/grep pipelines
  • json / jsonl emit serializable Invocation data, enabling patterns like:
restate inv list --status backing-off --output jsonl | jq -r .id | xargs restate inv cancel

The flag is wired as a global option in cli-util (--output in UiOpts), so extending it to other list/describe commands in follow-up PRs is straightforward.

Changes

  • crates/cli-util/src/opts.rs — new OutputFormat enum, added to UiOpts as a global flag
  • crates/cli-util/src/context.rsoutput_format() accessor
  • crates/cli-util/src/lib.rs — re-export OutputFormat
  • cli/src/clients/datafusion_helpers/mod.rsSerialize on Invocation, SerializeDisplay on InvocationState, SerializeAs impl for DatafusionServiceType
  • cli/src/commands/invocations/list.rs — format dispatch

Examples

--output table

   ID                   TARGET                STATUS     DEPLOYMENT         CREATED AT
   inv_13O9pdhD...sgh   Counter/test-key/add  completed  dp_158Betj...1L    2026-05-15T21:32:31+03:00

--output jsonl

  {"id":"inv_13O9pdhDeY4C75cnaN9rciSH7el4OT2sgh","target":"Counter/test-k
  ey/add","target_service_ty":"VirtualObject","created_at":"2026-05-15T21
  :32:31.869+03:00","status":"completed",...}
  {"id":"inv_1l3Hc716hrBy1SqoVNamSSRiWi7bWkykTL","target":"Counter/alice/
  get","target_service_ty":"VirtualObject","created_at":"2026-05-15T19:23
  :29.617+03:00","status":"completed",...}

Test plan

  • restate inv list --output human — same output as before
  • restate inv list --output table — plain tabular output, no colors
  • restate inv list --output json — valid JSON array
  • restate inv list --output jsonl | jq -r .id — extracts IDs correctly

Adds a global --output flag (human|table|json|jsonl) that makes
`restate inv list` usable in shell pipelines. The human format is
unchanged; table emits plain columns, json/jsonl emit serializable
Invocation data.

Closes restatedev#3872
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

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.

[CLI] Universal --output option for all get/list/describe commands

1 participant