Nick Vigilante
32e1f2502f
feat: add JSON output to coder tokens create ( #30135 )
...
Uses the `cliui` output helpers from #30508 .
`coder tokens create` printed only the new token's secret, so scripts
had to call `tokens view` afterwards to get the token's ID, expiry, and
scopes.
This adds `-o/--output` with `text` (default) and `json`.
The JSON document contains the token's metadata from `APIKeyByID` plus
the one-time `key`.
**Behavior change:** Additive.
The default output is still just the secret, so `$(coder tokens create
...)` keeps working.
The command now makes one extra API call after creating the token; if it
fails, the command prints a warning to stderr and still outputs the
secret rather than exiting with an error.
<details>
<summary>Decisions</summary>
- The metadata lookup uses the key ID parsed from the `<id>-<secret>`
token, the same convention `tokens view` and `tokens remove` use.
- A failed metadata lookup never fails the command, because the token
already exists and the secret can't be shown again.
</details>
Closes [CLI-14](https://linear.app/codercom/issue/CLI-14 )
_This PR was generated by Coder Agents on behalf of @nickvigilante._
2026-11-13 12:45:32 -05:00
..
2025-08-21 16:03:34 -04:00
2025-07-08 16:16:00 +00:00
2026-06-17 13:01:57 +02:00
2026-09-30 21:29:51 +00:00
2026-09-29 14:24:00 -07:00
2026-10-08 11:55:29 -04:00
2026-11-05 10:01:33 +05:00
2026-10-14 08:52:36 -07:00
2026-01-16 17:04:57 -09:00
2026-01-16 17:04:57 -09:00
2026-06-17 13:01:57 +02:00
2025-11-28 08:33:50 +02:00
2026-06-17 13:01:57 +02:00
2025-11-28 08:33:50 +02:00
2025-11-28 08:33:50 +02:00
2026-06-17 13:01:57 +02:00
2026-04-01 15:55:32 +00:00
2026-07-07 12:38:37 -07:00
2026-09-23 19:42:10 -06:00
2026-09-11 01:48:56 +00:00
2026-08-31 11:35:59 -04:00
2026-01-29 16:06:17 +01:00
2026-01-16 17:04:57 -09:00
2026-01-08 09:58:10 +00:00
2025-09-11 15:08:57 +02:00
2025-09-11 15:08:57 +02:00
2025-02-19 13:08:38 +00:00
2026-07-28 16:59:33 -07:00
2026-07-28 16:59:33 -07:00
2026-07-28 16:59:33 -07:00
2026-07-28 16:59:33 -07:00
2025-03-21 15:28:08 +00:00
2025-03-21 15:28:08 +00:00
2026-08-24 09:41:21 -05:00
2026-09-30 14:57:29 -04:00
2026-02-05 19:35:20 +11:00
2026-09-27 23:34:26 +02:00
2026-06-05 14:33:13 -05:00
2026-03-21 16:58:45 -08:00
2025-04-04 14:04:20 -04:00
2026-01-16 17:04:57 -09:00
2026-01-16 17:04:57 -09:00
2026-01-14 09:47:50 -08:00
2026-01-14 09:47:50 -08:00
2026-01-14 09:47:50 -08:00
2026-01-14 09:47:50 -08:00
2026-09-30 13:00:38 -04:00
2026-10-26 13:17:51 -04:00
2025-01-20 17:24:22 +00:00
2025-01-27 16:26:56 +00:00
2025-01-27 16:26:56 +00:00
2026-04-10 09:50:11 -05:00
2026-04-10 09:50:11 -05:00
2025-03-10 12:28:06 +00:00
2025-08-21 16:03:34 -04:00
2026-10-07 22:48:21 +00:00
2025-05-19 16:05:39 +01:00
2026-01-16 17:04:57 -09:00
2026-10-06 10:08:14 -04:00
2025-01-03 11:15:35 -06:00
2026-04-24 17:09:17 -04:00
2026-10-08 13:07:17 -04:00
2026-09-23 19:42:10 -06:00
2026-10-08 13:07:17 -04:00
2026-10-08 13:07:17 -04:00
2026-07-28 14:37:29 -07:00
2026-07-28 09:58:33 -06:00
2026-04-16 09:44:34 -07:00
2026-07-28 09:58:33 -06:00
2026-07-28 09:58:33 -06:00
2026-07-28 14:37:29 -07:00
2026-10-15 17:40:00 -05:00
2026-07-28 09:58:33 -06:00
2026-11-11 15:02:18 +00:00
2026-09-30 12:36:05 -04:00
2026-06-23 11:37:33 -05:00
2026-09-30 21:29:51 +00:00
2026-09-30 21:29:51 +00:00
2026-09-30 21:29:51 +00:00
2026-09-30 21:29:51 +00:00
2025-07-08 16:16:00 +00:00
2026-05-01 15:02:05 +02:00
2026-10-14 08:52:36 -07:00
2026-01-12 15:16:59 +01:00
2026-10-14 08:52:36 -07:00
2026-07-16 13:00:32 +03:00
2025-07-24 16:44:36 +01:00
2026-01-16 17:04:57 -09:00
2026-10-15 17:46:05 +00:00
2026-01-16 17:04:57 -09:00
2026-10-15 17:46:05 +00:00
2026-11-03 22:47:39 +00:00
2025-07-24 16:44:36 +01:00
2025-07-29 16:59:26 +01:00
2026-01-16 17:04:57 -09:00
2026-09-08 21:45:43 -06:00
2026-01-16 17:04:57 -09:00
2026-02-18 16:47:45 +11:00
2026-01-16 17:04:57 -09:00
2026-02-17 13:16:46 +00:00
2026-11-13 12:45:32 -05:00
2026-02-17 13:16:46 +00:00
2026-02-17 13:16:46 +00:00
2025-10-27 17:07:25 +01:00
2026-10-14 08:52:36 -07:00
2026-09-30 12:38:14 -04:00
2026-09-30 12:38:14 -04:00
2026-04-27 22:51:01 +00:00
2026-09-30 12:36:30 -04:00
2025-10-22 16:18:31 +11:00
2026-03-26 10:36:40 +00:00
2024-12-20 00:06:22 +02:00
2026-03-18 22:10:04 +00:00
2026-09-30 12:38:45 -04:00
2026-09-30 12:38:14 -04:00
2025-09-26 11:20:25 +01:00
2026-11-11 15:02:18 +00:00