Skip to content

Commit edd9029

Browse files
committed
Made printing results in shell as table optional and disabled by default
It's still possible to enable it by calling printResultsAsTable() in shell.
1 parent 6e6068e commit edd9029

File tree

1 file changed

+10
-3
lines changed
  • src/packages/pongo/src/commandLine

1 file changed

+10
-3
lines changed

src/packages/pongo/src/commandLine/shell.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ const calculateColumnWidths = (
3838
return columnWidths;
3939
};
4040

41+
let shouldDisplayResultsAsTable = false;
42+
43+
const printResultsAsTable = (print?: boolean) =>
44+
(shouldDisplayResultsAsTable = print === undefined || print === true);
45+
4146
// eslint-disable-next-line @typescript-eslint/no-explicit-any
42-
const printOutput = (obj: any): string => {
43-
return Array.isArray(obj) ? displayResultsAsTable(obj) : prettyJson(obj);
44-
};
47+
const printOutput = (obj: any): string =>
48+
Array.isArray(obj) && shouldDisplayResultsAsTable
49+
? displayResultsAsTable(obj)
50+
: prettyJson(obj);
4551

4652
// eslint-disable-next-line @typescript-eslint/no-explicit-any
4753
const displayResultsAsTable = (results: any[]): string => {
@@ -209,6 +215,7 @@ const startRepl = async (options: {
209215
shell.context.setLogLevel = setLogLevel;
210216
shell.context.setLogStyle = setLogStyle;
211217
shell.context.prettifyLogs = prettifyLogs;
218+
shell.context.printResultsAsTable = printResultsAsTable;
212219
shell.context.LogStyle = LogStyle;
213220
shell.context.LogLevel = LogLevel;
214221

0 commit comments

Comments
 (0)