Skip to content

Commit

Permalink
Merge pull request #2129 from Automattic/update/format-option
Browse files Browse the repository at this point in the history
fix: make the help text for the `format` option consistent for all commands
  • Loading branch information
yolih authored Nov 27, 2024
2 parents 90146fa + 5820a1c commit e0f471f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/bin/vip-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.'
Expand Down
3 changes: 1 addition & 2 deletions src/bin/vip-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -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( [
{
Expand Down
3 changes: 1 addition & 2 deletions src/bin/vip-slowlogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void command( {
appContext: true,
appQuery,
envContext: true,
format: false,
format: true,
module: 'slowlogs',
usage: baseUsage,
} )
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion src/bin/vip-validate-preflight.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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( [
{
Expand Down
7 changes: 5 additions & 2 deletions src/lib/cli/command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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“.'
);
}

Expand Down

0 comments on commit e0f471f

Please sign in to comment.