@switchboard.spot/cli 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,92 +0,0 @@
1
- /**
2
- * Workspace management commands.
3
- */
4
-
5
- import { accountRequest } from "../client.js";
6
- import { emit, globalFlags, printList } from "../output.js";
7
-
8
- export function registerWorkspacesCommands(program) {
9
- const workspaces = program.command("workspaces").description("Workspaces");
10
-
11
- workspaces
12
- .command("list")
13
- .description("List workspaces")
14
- .option("--trash <filter>", "active, deleted, or all", "active")
15
- .action(async (opts, cmd) => {
16
- const flags = globalFlags(cmd);
17
- const { data } = await accountRequest("GET", `/workspaces?trash=${opts.trash}`, {
18
- json: flags.json,
19
- });
20
- if (flags.json) {
21
- emit(data, flags);
22
- } else {
23
- printList("Workspaces:", data.data || [], (w) => ` ${w.id} ${w.name} (${w.slug})`);
24
- }
25
- });
26
-
27
- workspaces
28
- .command("show <id>")
29
- .description("Show a workspace")
30
- .option("--trash <filter>", "active, deleted, or all", "active")
31
- .action(async (id, opts, cmd) => {
32
- const flags = globalFlags(cmd);
33
- const { data } = await accountRequest("GET", `/workspaces/${id}?trash=${opts.trash}`, {
34
- json: flags.json,
35
- });
36
- emit(flags.json ? data : JSON.stringify(data, null, 2), flags);
37
- });
38
-
39
- workspaces
40
- .command("create")
41
- .description("Create a workspace")
42
- .requiredOption("--name <name>")
43
- .requiredOption("--slug <slug>")
44
- .action(async (opts, cmd) => {
45
- const flags = globalFlags(cmd);
46
- const { data } = await accountRequest("POST", "/workspaces", {
47
- body: { name: opts.name, slug: opts.slug },
48
- json: flags.json,
49
- });
50
- emit(flags.json ? data : `Created workspace ${data.name} (${data.id})`, flags);
51
- });
52
-
53
- workspaces
54
- .command("update <id>")
55
- .description("Update a workspace")
56
- .option("--name <name>")
57
- .option("--slug <slug>")
58
- .action(async (id, opts, cmd) => {
59
- const flags = globalFlags(cmd);
60
- const body = {};
61
- if (opts.name) body.name = opts.name;
62
- if (opts.slug) body.slug = opts.slug;
63
-
64
- const { data } = await accountRequest("PATCH", `/workspaces/${id}`, {
65
- body,
66
- json: flags.json,
67
- });
68
- emit(flags.json ? data : `Updated workspace ${data.name}`, flags);
69
- });
70
-
71
- workspaces
72
- .command("delete <id>")
73
- .description("Delete a workspace")
74
- .action(async (id, _opts, cmd) => {
75
- const flags = globalFlags(cmd);
76
- const { data } = await accountRequest("DELETE", `/workspaces/${id}`, {
77
- json: flags.json,
78
- });
79
- emit(flags.json ? data : `Deleted workspace ${data.name}`, flags);
80
- });
81
-
82
- workspaces
83
- .command("restore <id>")
84
- .description("Restore a deleted workspace")
85
- .action(async (id, _opts, cmd) => {
86
- const flags = globalFlags(cmd);
87
- const { data } = await accountRequest("POST", `/workspaces/${id}/restore`, {
88
- json: flags.json,
89
- });
90
- emit(flags.json ? data : `Restored workspace ${data.name}`, flags);
91
- });
92
- }