Skip to content

Commit

Permalink
Made printing shell options optional
Browse files Browse the repository at this point in the history
  • Loading branch information
oskardudycz committed Oct 9, 2024
1 parent edd9029 commit a5a63c5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@event-driven-io/pongo-core",
"version": "0.16.0",
"version": "0.16.1",
"description": "Pongo - Mongo with strong consistency on top of Postgres",
"type": "module",
"engines": {
Expand Down
2 changes: 1 addition & 1 deletion src/packages/pongo/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@event-driven-io/pongo",
"version": "0.16.0",
"version": "0.16.1",
"description": "Pongo - Mongo with strong consistency on top of Postgres",
"type": "module",
"scripts": {
Expand Down
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 @@ -108,6 +108,7 @@ const prettifyLogs = (logLevel?: string) => {

const startRepl = async (options: {
logging: {
printOptions: boolean;
logLevel: LogLevel;
logStyle: LogStyle;
};
Expand All @@ -118,13 +119,17 @@ const startRepl = async (options: {
};
connectionString: string | undefined;
}) => {
console.log(JSON.stringify(options));
// TODO: This will change when we have proper tracing and logging config
// For now, that's enough
setLogLevel(process.env.DUMBO_LOG_LEVEL ?? options.logging.logLevel);
setLogStyle(process.env.DUMBO_LOG_STYLE ?? options.logging.logStyle);

console.log(chalk.green('Starting Pongo Shell (version: 0.16.0)'));
console.log(chalk.green('Starting Pongo Shell (version: 0.16.1)'));

if (options.logging.printOptions) {
console.log(chalk.green('With Options:'));
console.log(prettyJson(options));
}

const connectionString =
options.connectionString ??
Expand Down Expand Up @@ -247,6 +252,7 @@ interface ShellOptions {
logStyle?: string;
logLevel?: string;
prettyLog?: boolean;
printOptions?: boolean;
}

const shellCommand = new Command('shell')
Expand All @@ -269,6 +275,7 @@ const shellCommand = new Command('shell')
'-no-migrations, --disable-auto-migrations',
'Disable automatic migrations',
)
.option('-o, --print-options', 'Print shell options')
.option(
'-ll, --log-level <logLevel>',
'Log level: DISABLED, INFO, LOG, WARN, ERROR',
Expand All @@ -277,12 +284,12 @@ const shellCommand = new Command('shell')
.option('-ls, --log-style', 'Log style: RAW, PRETTY', 'RAW')
.option('-p, --pretty-log', 'Turn on logging with prettified output')
.action(async (options: ShellOptions) => {
console.log(JSON.stringify(options));
const { collection, database } = options;
const connectionString = options.connectionString;

await startRepl({
logging: {
printOptions: options.printOptions === true,
logStyle: options.prettyLog
? LogStyle.PRETTY
: ((options.logStyle as LogStyle | undefined) ?? LogStyle.RAW),
Expand Down

0 comments on commit a5a63c5

Please sign in to comment.