| 540 | } |
| 541 | |
| 542 | async function runTokenGet(client: ArtifactClient, args: string[]): Promise<ArtifactsCLIResult> { |
| 543 | const parsed = parseFlags(args, {}); |
| 544 | if ("error" in parsed) return argvError("token get", parsed.error); |
| 545 | const [repo, id] = parsed.positional; |
| 546 | if (repo === undefined) return argvError("token get", "missing <repo>"); |
| 547 | if (id === undefined) return argvError("token get", "missing <id>"); |
| 548 | if (parsed.positional.length > 2) { |
| 549 | return argvError("token get", `unexpected argument '${parsed.positional[2]}'`); |
| 550 | } |
| 551 | try { |
| 552 | return ok(json(await client.getToken(repo, id))); |
| 553 | } catch (cause) { |
| 554 | return mapError("token get", cause); |
| 555 | } |
| 556 | } |
| 557 | |
| 558 | async function runTokenDelete(client: ArtifactClient, args: string[]): Promise<ArtifactsCLIResult> { |
| 559 | const parsed = parseFlags(args, {}); |