Skip to content

Commit

Permalink
Update the slowlogs command to follow the VIP-CLI styleguide.
Browse files Browse the repository at this point in the history
  • Loading branch information
terriann committed Apr 16, 2024
1 parent dbf9928 commit 487bed5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 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: true,
module: 'slowlogs',
usage: baseUsage,
} )
.option( 'limit', 'The maximum number of log lines', 500 )
.option( 'format', 'Output the log lines in CSV or JSON format', 'text' )
.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 text format.',
usage: exampleUsage,
},
{
usage: 'vip @mysite.production slowlogs --limit 100',
description: 'Get the most recent 100 slowlog entries',
description:
'Retrieve the 100 most recent entries from the MySQL slow query logs in the default text format.',
usage: `${ exampleUsage } --limit=100`,
},
{
usage: 'vip @mysite.production slowlogs --limit 100 --format csv',
description:
'Get the most recent 100 slowlog entries formatted as comma-separated values (CSV)',
'Retrieve the 100 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 the 100 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', 'Run operations on your VIP application database' )
.command( 'sync', 'Sync production to a development environment' )
.command( 'whoami', 'Display details about the currently logged-in user' )
Expand Down

0 comments on commit 487bed5

Please sign in to comment.