Skip to content

feat: add output formats to coder organizations members edit-roles - #30145

Merged
nickvigilante merged 5 commits into
mainfrom
vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with
Nov 13, 2026
Merged

nickvigilante merged 5 commits into
mainfrom
vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Uses the cliui output helpers from #30508.

coder organizations members edit-roles printed only Member roles updated to [...], while members list supports -o table|json and -c.

It now accepts -o text|table|json and -c.
Table and JSON show the updated member using the members list row type and columns.

Behavior change: Additive.
Default text output is unchanged.
The command now fetches the member after updating roles, on every invocation; if that read fails, it exits with an error even though the roles were already updated.

Decisions
  • The update endpoint doesn't return user data, so the member is re-read to build the table and JSON rows.

Closes CLI-27

This PR was generated by Coder Agents on behalf of @nickvigilante.

@linear-code

linear-code Bot commented Sep 30, 2026

Copy link
Copy Markdown

CLI-27

@nickvigilante
nickvigilante marked this pull request as ready for review September 30, 2026 00:39
@nickvigilante nickvigilante added the cli Area: CLI label Oct 5, 2026
@nickvigilante
nickvigilante force-pushed the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch from e1b82fc to 82060c7 Compare October 8, 2026 15:45
@nickvigilante
nickvigilante changed the base branch from main to vigilante/cli-56-cliui-add-shared-text-formatter-and-write-helpers-for-o October 8, 2026 15:45
@nickvigilante
nickvigilante force-pushed the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch from 82060c7 to 85402d1 Compare October 8, 2026 18:22
nickvigilante added a commit that referenced this pull request Oct 8, 2026
…pers (#30508)

Adds two small helpers to `cli/cliui/output.go` so commands that add
`-o/--output` don't repeat the same boilerplate, as suggested in
#30152 (comment) by
@jeremyruppel.

- `TextFormatFunc[T]` wraps `ChangeFormatterData(TextFormat(), ...)`
with the type assertion and "expected X, got Y" error, so a command only
supplies its render function.
- `(*OutputFormatter).WriteLine` formats data and writes it to an
`io.Writer` with a trailing newline, replacing the `Format` + `Fprintln`
block.

No existing callers change in this PR. These PRs are stacked on it and
use the helpers:

- #30135 `coder tokens create`
- #30139 `coder ai-gateway keys create`
- #30145 `coder organizations members edit-roles`
- #30152 `coder provisioner keys create`

Migrating the existing callers on `main` (for example
`cli/organization.go`, `enterprise/cli/workspaceproxy.go`) is left for a
follow-up, since some of them print with `Fprint` rather than `Fprintln`
and need care to keep output identical.

Refs CLI-56

<details>
<summary>Decision log</summary>

- A global `-o` flag on the root command was ruled out because `coder
config-ssh` already uses `-o` for `--ssh-option`.
- The "one-time secret plus metadata" response structs in #30135 and
#30152 stay local to each command, since they embed different SDK types
and a shared helper would save little.
- `WriteLine` uses `Fprintln` to match the four stacked PRs and most
existing callers.
It was renamed from `Write` during review so the trailing newline is
visible at call sites and the method is not confused with `io.Writer`.

</details>

> [!NOTE]
> This PR was generated by Coder Agents on behalf of @nickvigilante.
Base automatically changed from vigilante/cli-56-cliui-add-shared-text-formatter-and-write-helpers-for-o to main October 8, 2026 19:41
@nickvigilante
nickvigilante force-pushed the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch from 85402d1 to 5ee2662 Compare October 16, 2026 18:35
@nickvigilante
nickvigilante requested a review from untra October 16, 2026 19:36
@github-actions github-actions Bot added the stale This issue is like stale bread. label Nov 6, 2026
@github-actions github-actions Bot closed this Nov 9, 2026
@nickvigilante nickvigilante reopened this Nov 10, 2026
@nickvigilante
nickvigilante temporarily deployed to main November 10, 2026 17:35 — with GitHub Actions Inactive
@nickvigilante nickvigilante removed the stale This issue is like stale bread. label Nov 10, 2026
@nickvigilante

Copy link
Copy Markdown
Collaborator Author

@untra Another nudge

@nickvigilante
nickvigilante force-pushed the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch from 5ee2662 to d07b2d6 Compare November 11, 2026 00:04
@nickvigilante
nickvigilante temporarily deployed to main November 11, 2026 00:04 — with GitHub Actions Inactive
`coder organizations members edit-roles` printed only `Member roles
updated to [...]`, while `members list` supports `-o table|json` and
`-c`.

Linear: CLI-27
TableFormat expects a slice, so edit-roles -o table panicked when given a
single member. Add a table test with -c.
@nickvigilante
nickvigilante force-pushed the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch from d07b2d6 to 973dfe4 Compare November 13, 2026 17:59
@nickvigilante
nickvigilante temporarily deployed to main November 13, 2026 17:59 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to docs-preview November 13, 2026 18:02 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 13, 2026 18:12 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to docs-preview November 13, 2026 18:15 — with GitHub Actions Inactive
@nickvigilante

Copy link
Copy Markdown
Collaborator Author

@untra Apologies, CI is finally green now

@nickvigilante
nickvigilante merged commit bd268cb into main Nov 13, 2026
35 checks passed
@nickvigilante
nickvigilante deleted the vigilante/cli-27-coder-organizations-members-edit-roles-add-o-output-with branch November 13, 2026 19:33
@nickvigilante
nickvigilante temporarily deployed to docs-preview November 13, 2026 19:33 — with GitHub Actions Inactive
@nickvigilante
nickvigilante temporarily deployed to main November 13, 2026 19:33 — with GitHub Actions Inactive
@github-actions github-actions Bot locked and limited conversation to collaborators Nov 13, 2026

This branch was previously deployed

2 inactive deployments
docs-preview — a232d327 Deployed Nov 13, 2026 by nickvigilante via cleanup #51
main — a232d327 Deployed Nov 13, 2026 by nickvigilante via cla #256944
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cli Area: CLI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants