Skip to content

Commit 19c0260

Browse files
authored
feat: Add default table fields to all resources (#47)
1 parent 335911b commit 19c0260

51 files changed

Lines changed: 262 additions & 42 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

commands/autoscaling-group/create/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { dataTable } from "../../../lib/data-table.ts";
55
import { fields } from "../../../flags.ts";
66
import { pickJson } from "../../../lib/pick-json.ts";
77
import { autoscalingGroups } from "../../../api/autoscaling-groups.ts";
8+
import { defaultFields } from "../mod.ts";
89

910
/**
1011
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -80,7 +81,9 @@ export const create = command("create", {
8081
if (flags.json) {
8182
yield pickJson(result, flags.fields);
8283
} else {
83-
for await (const line of dataTable([result], flags.fields)) {
84+
for await (
85+
const line of dataTable([result], flags.fields ?? defaultFields)
86+
) {
8487
yield line;
8588
}
8689
}

commands/autoscaling-group/delete/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { dataTable } from "../../../lib/data-table.ts";
66
import { fields } from "../../../flags.ts";
77
import { pickJson } from "../../../lib/pick-json.ts";
88
import { autoscalingGroups } from "../../../api/autoscaling-groups.ts";
9+
import { defaultFields } from "../mod.ts";
910

1011
/**
1112
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -52,7 +53,9 @@ export const del = command("delete", {
5253
if (flags.json) {
5354
yield pickJson(result, flags.fields);
5455
} else {
55-
for await (const line of dataTable([result], flags.fields)) {
56+
for await (
57+
const line of dataTable([result], flags.fields ?? defaultFields)
58+
) {
5659
yield line;
5760
}
5861
}

commands/autoscaling-group/get/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { dataTable } from "../../../lib/data-table.ts";
66
import { fields } from "../../../flags.ts";
77
import { pickJson } from "../../../lib/pick-json.ts";
88
import { autoscalingGroups } from "../../../api/autoscaling-groups.ts";
9+
import { defaultFields } from "../mod.ts";
910

1011
/**
1112
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -52,7 +53,9 @@ export const get = command("get", {
5253
if (flags.json) {
5354
yield pickJson(result, flags.fields);
5455
} else {
55-
for await (const line of dataTable([result], flags.fields)) {
56+
for await (
57+
const line of dataTable([result], flags.fields ?? defaultFields)
58+
) {
5659
yield line;
5760
}
5861
}

commands/autoscaling-group/list/mod.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { loading } from "../../../lib/loading.ts";
66
import * as psFlags from "../../../flags.ts";
77
import { pickJson } from "../../../lib/pick-json.ts";
88
import { config } from "../../../config.ts";
9+
import { defaultFields } from "../mod.ts";
910

1011
/**
1112
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -57,7 +58,12 @@ export const list = command("list", {
5758
asserts(result.ok, result);
5859

5960
if (!flags.json) {
60-
for await (const line of dataTable(result.data.items, flags.fields)) {
61+
for await (
62+
const line of dataTable(
63+
result.data.items,
64+
flags.fields ?? defaultFields,
65+
)
66+
) {
6167
yield line;
6268
}
6369
} else {

commands/autoscaling-group/mod.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { list } from "./list/mod.ts";
55
import { del } from "./delete/mod.ts";
66
import { update } from "./update/mod.ts";
77

8+
export const defaultFields = [
9+
"id",
10+
"name",
11+
"clusterId",
12+
"machineType",
13+
"min",
14+
"max",
15+
"current",
16+
];
17+
818
/**
919
* This variable is automatically generated by `zcli add`. Do not remove this
1020
* or change its name unless you're no longer using `zcli add`.

commands/autoscaling-group/update/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { fields } from "../../../flags.ts";
66
import { pickJson } from "../../../lib/pick-json.ts";
77
import { autoscalingGroups } from "../../../api/autoscaling-groups.ts";
88
import { input } from "../../../prompts/input.ts";
9+
import { defaultFields } from "../mod.ts";
910

1011
/**
1112
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -98,7 +99,9 @@ export const update = command("update", {
9899
if (flags.json) {
99100
yield pickJson(result, flags.fields);
100101
} else {
101-
for await (const line of dataTable([result], flags.fields)) {
102+
for await (
103+
const line of dataTable([result], flags.fields ?? defaultFields)
104+
) {
102105
yield line;
103106
}
104107
}

commands/deployment/get/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { dataTable } from "../../../lib/data-table.ts";
55
import { pickJson } from "../../../lib/pick-json.ts";
66
import { loading } from "../../../lib/loading.ts";
77
import { deployments } from "../../../api/deployments.ts";
8+
import { defaultFields } from "../mod.ts";
89

910
/**
1011
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -73,7 +74,9 @@ export const get = command("get", {
7374
asserts(result.ok, result);
7475

7576
if (!flags.json) {
76-
for await (const line of dataTable([result.data], flags.fields)) {
77+
for await (
78+
const line of dataTable([result.data], flags.fields ?? defaultFields)
79+
) {
7780
yield line;
7881
}
7982
} else {

commands/deployment/list/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as psFlags from "../../../flags.ts";
55
import { asserts } from "../../../lib/asserts.ts";
66
import { dataTable } from "../../../lib/data-table.ts";
77
import { pickJson } from "../../../lib/pick-json.ts";
8+
import { defaultFields } from "../mod.ts";
89

910
/**
1011
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -42,7 +43,9 @@ export const list = command("list", {
4243
asserts(result.ok, result);
4344

4445
if (!flags.json) {
45-
for await (const line of dataTable(result.data.items, flags.fields)) {
46+
for await (
47+
const line of dataTable(result.data.items, flags.fields ?? defaultFields)
48+
) {
4649
yield line;
4750
}
4851
} else {

commands/deployment/mod.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ import { list } from "./list/mod.ts";
44
import { delete_ } from "./delete/mod.ts";
55
import { up } from "./up/mod.ts";
66

7+
export const defaultFields = [
8+
"id",
9+
"name",
10+
"projectId",
11+
"endpoint",
12+
];
13+
714
/**
815
* This variable is automatically generated by `zcli add`. Do not remove this
916
* or change its name unless you're no longer using `zcli add`.

commands/machine/create/mod.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
MachinePublicIpTypeSchema,
1111
MachineRestorePointFrequencySchema,
1212
} from "../schemas.ts";
13+
import { defaultFields } from "../mod.ts";
1314

1415
/**
1516
* This variable is automatically generated by `zcli add`. Do not remove this
@@ -159,7 +160,9 @@ export const create = command("create", {
159160
if (flags.json) {
160161
yield pickJson(result, flags.fields);
161162
} else {
162-
for await (const line of dataTable([result], flags.fields)) {
163+
for await (
164+
const line of dataTable([result], flags.fields ?? defaultFields)
165+
) {
163166
yield line;
164167
}
165168
}

0 commit comments

Comments
 (0)