Skip to content

Commit 4670d35

Browse files
committed
Address CLI PR review feedback
1 parent c792ba5 commit 4670d35

2 files changed

Lines changed: 22 additions & 20 deletions

File tree

templates/cli/cli.ts.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ if (process.argv.includes('-v') || process.argv.includes('--version')) {
8383
.helpOption('-h, --help', 'Display help for command')
8484
.version(version, '-v, --version', 'Output the version number')
8585
.option('-V, --verbose', 'Show complete error log')
86-
.option('-j, --json', 'Output in JSON format')
87-
.option('-R, --raw', 'Output raw JSON (secrets still redacted unless --show-secrets is set)')
86+
.option('-j, --json', 'Output filtered JSON without empty values')
87+
.option('-R, --raw', 'Output full JSON response (secrets still redacted unless --show-secrets is set)')
8888
.option('--show-secrets', 'Display sensitive values like secrets and tokens in output')
8989
.hook('preAction', migrate)
9090
.option('-f,--force', 'Flag to confirm all warnings')

templates/cli/lib/parser.ts

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ const endRender = (): void => {
100100
}
101101
};
102102

103+
const withRender = <T>(callback: () => T): T => {
104+
beginRender();
105+
106+
try {
107+
return callback();
108+
} finally {
109+
endRender();
110+
}
111+
};
112+
103113
const isSensitiveKey = (key: string): boolean => {
104114
const normalizedKey = key.toLowerCase().replace(/[^a-z0-9]/g, "");
105115

@@ -222,9 +232,7 @@ const filterData = (data: JsonObject): JsonObject => {
222232
};
223233

224234
export const parse = (data: JsonObject): void => {
225-
beginRender();
226-
227-
try {
235+
withRender(() => {
228236
const sanitizedData = maskSensitiveData(data) as JsonObject;
229237

230238
if (cliConfig.raw) {
@@ -285,9 +293,7 @@ export const parse = (data: JsonObject): void => {
285293
printedScalar = true;
286294
}
287295
}
288-
} finally {
289-
endRender();
290-
}
296+
});
291297
};
292298

293299
const MAX_COL_WIDTH = 40;
@@ -312,9 +318,7 @@ const formatCellValue = (value: unknown): string => {
312318
};
313319

314320
export const drawTable = (data: Array<JsonObject | null | undefined>): void => {
315-
beginRender();
316-
317-
try {
321+
withRender(() => {
318322
if (data.length == 0) {
319323
console.log("[]");
320324
return;
@@ -395,21 +399,21 @@ export const drawTable = (data: Array<JsonObject | null | undefined>): void => {
395399
colWidths: columns.map(() => null) as (number | null)[],
396400
wordWrap: false,
397401
chars: {
398-
top: " ",
402+
"top": " ",
399403
"top-mid": " ",
400404
"top-left": " ",
401405
"top-right": " ",
402-
bottom: " ",
406+
"bottom": " ",
403407
"bottom-mid": " ",
404408
"bottom-left": " ",
405409
"bottom-right": " ",
406-
left: " ",
410+
"left": " ",
407411
"left-mid": " ",
408-
mid: chalk.cyan("─"),
412+
"mid": chalk.cyan("─"),
409413
"mid-mid": chalk.cyan("┼"),
410-
right: " ",
414+
"right": " ",
411415
"right-mid": " ",
412-
middle: chalk.cyan("│"),
416+
"middle": chalk.cyan("│"),
413417
},
414418
});
415419

@@ -421,9 +425,7 @@ export const drawTable = (data: Array<JsonObject | null | undefined>): void => {
421425
table.push(rowValues);
422426
});
423427
console.log(table.toString());
424-
} finally {
425-
endRender();
426-
}
428+
});
427429
};
428430

429431
export const drawJSON = (data: unknown): void => {

0 commit comments

Comments
 (0)