Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the slowlogs command to follow the VIP-CLI styleguide #1782

Merged
merged 3 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 17 additions & 10 deletions src/bin/vip-slowlogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ const DEFAULT_POLLING_DELAY_IN_SECONDS = 30;
const MIN_POLLING_DELAY_IN_SECONDS = 5;
const MAX_POLLING_DELAY_IN_SECONDS = 300;

const exampleUsage = 'vip @example-app.develop slowlogs';
const baseUsage = 'vip slowlogs';

export async function getSlowlogs( arg: string[], opt: GetSlowLogsOptions ): Promise< void > {
validateInputs( opt.limit, opt.format );

Expand Down Expand Up @@ -188,26 +191,30 @@ void command( {
envContext: true,
format: false,
module: 'slowlogs',
usage: baseUsage,
} )
.option( 'limit', 'The maximum number of log lines', 500 )
.option( 'format', 'Output the log lines in CSV or JSON format', 'table' )
.option( 'limit', 'The maximum number of log entries', 500 )
.option( 'format', 'Output the log entries in CSV or JSON format', 'table' )
.examples( [
{
description: 'Get the most recent app slowlogs',
usage: 'vip @mysite.production slowlogs',
description:
'Retrieve up to 500 of the most recent entries from the MySQL slow query logs in the default format.',
usage: exampleUsage,
},
{
usage: 'vip @mysite.production slowlogs --limit 100',
description: 'Get the most recent 100 slowlog entries',
description:
'Retrieve up to 50 of the most recent entries from the MySQL slow query logs in the default format.',
usage: `${ exampleUsage } --limit=50`,
},
{
usage: 'vip @mysite.production slowlogs --limit 100 --format csv',
description:
'Get the most recent 100 slowlog entries formatted as comma-separated values (CSV)',
'Retrieve up to 100 of the most recent entries from the MySQL slow query logs in CSV format.',
usage: `${ exampleUsage } --limit=100 --format=csv`,
},
{
usage: 'vip @mysite.production slowlogs --limit 100 --format json',
description: 'Get the most recent 100 slowlog entries formatted as JSON',
description:
'Retrieve up to 100 of the most recent entries from the MySQL slow query logs in JSON format.',
usage: `${ exampleUsage } --limit=100 --format=json`,
},
] )
.argv( process.argv, getSlowlogs );
2 changes: 1 addition & 1 deletion src/bin/vip.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const runCmd = async function () {
.command( 'import', 'Import media or SQL files into your VIP applications' )
.command( 'logs', 'Get logs from your VIP applications' )
.command( 'search-replace', 'Perform search and replace tasks on files' )
.command( 'slowlogs', 'Get slowlogs from your VIP applications' )
.command( 'slowlogs', 'Retrieve MySQL slow query logs from an environment.' )
.command( 'db', "Access an environment's database." )
.command( 'sync', 'Sync production to a development environment' )
.command( 'whoami', 'Retrieve details about the current authenticated VIP-CLI user.' )
Expand Down