From 046ce189af1dbebf48286f297850e305eeb44b8e Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Wed, 27 Nov 2024 16:22:04 +0200 Subject: [PATCH 1/2] fix: make the help text for the `format` option consistent for all commands --- src/bin/vip-app-list.js | 2 +- src/bin/vip-logs.js | 3 +-- src/bin/vip-slowlogs.ts | 3 +-- src/bin/vip-validate-preflight.js | 2 +- src/lib/cli/command.js | 7 +++++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/bin/vip-app-list.js b/src/bin/vip-app-list.js index 4c08fc251..df21a56ff 100755 --- a/src/bin/vip-app-list.js +++ b/src/bin/vip-app-list.js @@ -8,7 +8,7 @@ import { trackEvent } from '../lib/tracker'; const baseUsage = 'vip app list'; -command( { format: true, usage: baseUsage } ) +command( { usage: baseUsage } ) .examples( [ { usage: diff --git a/src/bin/vip-logs.js b/src/bin/vip-logs.js index 2d3b77045..c93e58c43 100755 --- a/src/bin/vip-logs.js +++ b/src/bin/vip-logs.js @@ -251,8 +251,7 @@ command( { .option( 'follow', 'Output new entries as they are generated.' ) .option( 'format', - 'Render output in a particular format. Accepts “csv”, “json”, and “text”.', - 'table' + 'Render output in a particular format. Accepts “table“ (default), “csv“, “json“, and “text”.' ) .examples( [ { diff --git a/src/bin/vip-slowlogs.ts b/src/bin/vip-slowlogs.ts index 4b84f897c..f2a8652c2 100755 --- a/src/bin/vip-slowlogs.ts +++ b/src/bin/vip-slowlogs.ts @@ -190,7 +190,7 @@ void command( { appContext: true, appQuery, envContext: true, - format: false, + format: true, module: 'slowlogs', usage: baseUsage, } ) @@ -199,7 +199,6 @@ void command( { 'Set the maximum number of log entries. Accepts an integer value between 1 and 500.', 500 ) - .option( 'format', 'Render output in a particular format. Accepts “csv”, and “json”.', 'table' ) .examples( [ { description: diff --git a/src/bin/vip-validate-preflight.js b/src/bin/vip-validate-preflight.js index 7318ccab4..658da1aca 100755 --- a/src/bin/vip-validate-preflight.js +++ b/src/bin/vip-validate-preflight.js @@ -560,6 +560,7 @@ function sanitizeArgsForTracking( args ) { let commandOpts = { module: 'harmonia', + format: true, }; // The @app.env selector is optional, so we need to check if it was passed @@ -601,7 +602,6 @@ command( commandOpts ) [ 'p', 'port' ], 'Configure the port to use for the app (defaults to a random port between 3001 and 3999)' ) - .option( 'format', 'Output the log lines in CSV or JSON format', 'table' ) .option( [ 'P', 'path' ], 'Path to the app to be tested', process.cwd() ) .examples( [ { diff --git a/src/lib/cli/command.js b/src/lib/cli/command.js index 5d3138f4f..875911ab1 100644 --- a/src/lib/cli/command.js +++ b/src/lib/cli/command.js @@ -67,6 +67,10 @@ args.argv = async function ( argv, cb ) { debug: false, } ); + if ( _opts.format && ! options.format ) { + options.format = 'table'; + } + if ( options.h || options.help ) { this.showHelp(); } @@ -603,8 +607,7 @@ export default function ( opts ) { if ( _opts.format ) { args.option( 'format', - 'Render output in a particular format. Accepts “csv”, and “json”.', - 'table' + 'Render output in a particular format. Accepts “table“ (default), “csv“, and “json“.' ); } From 5820a1c9cbcb439141ef7317a45a8a9a54886781 Mon Sep 17 00:00:00 2001 From: Volodymyr Kolesnykov Date: Wed, 27 Nov 2024 19:05:08 +0200 Subject: [PATCH 2/2] fix: wrong file --- src/bin/vip-app-list.js | 2 +- src/bin/vip-app.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/vip-app-list.js b/src/bin/vip-app-list.js index df21a56ff..4c08fc251 100755 --- a/src/bin/vip-app-list.js +++ b/src/bin/vip-app-list.js @@ -8,7 +8,7 @@ import { trackEvent } from '../lib/tracker'; const baseUsage = 'vip app list'; -command( { usage: baseUsage } ) +command( { format: true, usage: baseUsage } ) .examples( [ { usage: diff --git a/src/bin/vip-app.js b/src/bin/vip-app.js index f1aab251f..8c4efc97d 100755 --- a/src/bin/vip-app.js +++ b/src/bin/vip-app.js @@ -6,7 +6,7 @@ import app from '../lib/api/app'; import command, { getEnvIdentifier } from '../lib/cli/command'; import { trackEvent } from '../lib/tracker'; -command( { requiredArgs: 1, format: true } ) +command( { requiredArgs: 1 } ) .example( 'vip app list', 'Retrieve a list of applications that can be accessed by the current authenticated VIP-CLI user.'