Skip to content

Commit

Permalink
Made printing results in shell as table optional and disabled by default
Browse files Browse the repository at this point in the history
It's still possible to enable it by calling printResultsAsTable() in shell.
  • Loading branch information
oskardudycz committed Oct 9, 2024
1 parent 6e6068e commit edd9029
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/packages/pongo/src/commandLine/shell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,16 @@ const calculateColumnWidths = (
return columnWidths;
};

let shouldDisplayResultsAsTable = false;

const printResultsAsTable = (print?: boolean) =>
(shouldDisplayResultsAsTable = print === undefined || print === true);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const printOutput = (obj: any): string => {
return Array.isArray(obj) ? displayResultsAsTable(obj) : prettyJson(obj);
};
const printOutput = (obj: any): string =>
Array.isArray(obj) && shouldDisplayResultsAsTable
? displayResultsAsTable(obj)
: prettyJson(obj);

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const displayResultsAsTable = (results: any[]): string => {
Expand Down Expand Up @@ -209,6 +215,7 @@ const startRepl = async (options: {
shell.context.setLogLevel = setLogLevel;
shell.context.setLogStyle = setLogStyle;
shell.context.prettifyLogs = prettifyLogs;
shell.context.printResultsAsTable = printResultsAsTable;
shell.context.LogStyle = LogStyle;
shell.context.LogLevel = LogLevel;

Expand Down

0 comments on commit edd9029

Please sign in to comment.