From 8df424c38ca3e8fb0d0ccd1f46ee7a0f13f255f1 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Fri, 17 Apr 2026 16:05:09 +0530 Subject: [PATCH 1/3] Standardized all command arguments - Made argument names more verbose and readable - Made sure they are represented as camelCase in the codebase - Updated utils.ts to display arguments as `SNAKE_CASE` --- src/commands/accounts/logout.ts | 4 +-- src/commands/accounts/switch.ts | 6 ++-- src/commands/apps/update.ts | 10 +++---- src/commands/bench/publisher.ts | 14 +++++---- src/commands/bench/subscriber.ts | 12 ++++---- src/commands/channels/annotations/delete.ts | 12 ++++---- src/commands/channels/annotations/get.ts | 8 ++--- src/commands/channels/annotations/publish.ts | 12 ++++---- .../channels/annotations/subscribe.ts | 4 +-- src/commands/channels/append.ts | 8 ++--- src/commands/channels/delete.ts | 8 ++--- src/commands/channels/history.ts | 4 +-- src/commands/channels/inspect.ts | 4 +-- src/commands/channels/occupancy/get.ts | 6 ++-- src/commands/channels/occupancy/subscribe.ts | 6 ++-- src/commands/channels/presence/enter.ts | 6 ++-- src/commands/channels/presence/get.ts | 6 ++-- src/commands/channels/presence/subscribe.ts | 6 ++-- src/commands/channels/publish.ts | 24 +++++++-------- src/commands/channels/subscribe.ts | 2 +- src/commands/channels/update.ts | 8 ++--- src/commands/integrations/delete.ts | 6 ++-- src/commands/push/devices/get.ts | 4 +-- src/commands/push/devices/remove.ts | 4 +-- src/commands/rooms/messages/delete.ts | 30 +++++++++---------- src/commands/rooms/messages/history.ts | 14 ++++----- .../rooms/messages/reactions/remove.ts | 4 +-- src/commands/rooms/messages/reactions/send.ts | 4 +-- .../rooms/messages/reactions/subscribe.ts | 8 ++--- src/commands/rooms/messages/send.ts | 18 +++++------ src/commands/rooms/messages/subscribe.ts | 2 +- src/commands/rooms/messages/update.ts | 30 +++++++++---------- src/commands/rooms/occupancy/get.ts | 6 ++-- src/commands/rooms/occupancy/subscribe.ts | 4 +-- src/commands/rooms/presence/enter.ts | 4 +-- src/commands/rooms/presence/get.ts | 6 ++-- src/commands/rooms/presence/subscribe.ts | 4 +-- src/commands/rooms/reactions/send.ts | 4 +-- src/commands/rooms/reactions/subscribe.ts | 6 ++-- src/commands/rooms/typing/keystroke.ts | 6 ++-- src/commands/rooms/typing/subscribe.ts | 6 ++-- src/commands/spaces/create.ts | 4 +-- src/commands/spaces/cursors/get.ts | 4 +-- src/commands/spaces/cursors/set.ts | 4 +-- src/commands/spaces/cursors/subscribe.ts | 4 +-- src/commands/spaces/get.ts | 4 +-- src/commands/spaces/locations/get.ts | 4 +-- src/commands/spaces/locations/set.ts | 4 +-- src/commands/spaces/locations/subscribe.ts | 4 +-- src/commands/spaces/locks/acquire.ts | 4 +-- src/commands/spaces/locks/get.ts | 4 +-- src/commands/spaces/locks/subscribe.ts | 4 +-- src/commands/spaces/members/enter.ts | 4 +-- src/commands/spaces/members/get.ts | 4 +-- src/commands/spaces/members/subscribe.ts | 4 +-- src/commands/spaces/occupancy/get.ts | 6 ++-- src/commands/spaces/occupancy/subscribe.ts | 6 ++-- src/commands/spaces/subscribe.ts | 4 +-- src/commands/stats/app.ts | 4 +-- src/help.ts | 24 +++++++++++++-- test/unit/commands/spaces/spaces.test.ts | 2 +- 61 files changed, 232 insertions(+), 210 deletions(-) diff --git a/src/commands/accounts/logout.ts b/src/commands/accounts/logout.ts index b6241de22..a9b03a7ad 100644 --- a/src/commands/accounts/logout.ts +++ b/src/commands/accounts/logout.ts @@ -6,7 +6,7 @@ import { promptForConfirmation } from "../../utils/prompt-confirmation.js"; export default class AccountsLogout extends ControlBaseCommand { static override args = { - alias: Args.string({ + accountAlias: Args.string({ description: "Alias of the account to log out from (defaults to current account)", required: false, @@ -32,7 +32,7 @@ export default class AccountsLogout extends ControlBaseCommand { // Determine which account to log out from const targetAlias = - args.alias || this.configManager.getCurrentAccountAlias(); + args.accountAlias || this.configManager.getCurrentAccountAlias(); if (!targetAlias) { this.fail( diff --git a/src/commands/accounts/switch.ts b/src/commands/accounts/switch.ts index e45ed3c27..73cff5b3d 100644 --- a/src/commands/accounts/switch.ts +++ b/src/commands/accounts/switch.ts @@ -7,7 +7,7 @@ import { formatResource } from "../../utils/output.js"; export default class AccountsSwitch extends ControlBaseCommand { static override args = { - alias: Args.string({ + accountAlias: Args.string({ description: "Alias of the account to switch to", required: false, }), @@ -49,8 +49,8 @@ export default class AccountsSwitch extends ControlBaseCommand { } // If alias is provided, switch directly - if (args.alias) { - await this.switchToAccount(args.alias, accounts, flags); + if (args.accountAlias) { + await this.switchToAccount(args.accountAlias, accounts, flags); return; } diff --git a/src/commands/apps/update.ts b/src/commands/apps/update.ts index a0275ea74..c661e180b 100644 --- a/src/commands/apps/update.ts +++ b/src/commands/apps/update.ts @@ -5,7 +5,7 @@ import { formatLabel, formatResource } from "../../utils/output.js"; export default class AppsUpdateCommand extends ControlBaseCommand { static args = { - id: Args.string({ + appId: Args.string({ description: "App ID to update", required: true, }), @@ -44,13 +44,13 @@ export default class AppsUpdateCommand extends ControlBaseCommand { "At least one update parameter (--name or --tls-only) must be provided", flags, "appUpdate", - { appId: args.id }, + { appId: args.appId }, ); } try { const controlApi = this.createControlApi(flags); - this.logProgress(`Updating app ${formatResource(args.id)}`, flags); + this.logProgress(`Updating app ${formatResource(args.appId)}`, flags); const updateData: { name?: string; tlsOnly?: boolean } = {}; @@ -62,7 +62,7 @@ export default class AppsUpdateCommand extends ControlBaseCommand { updateData.tlsOnly = flags["tls-only"]; } - const app = await controlApi.updateApp(args.id, updateData); + const app = await controlApi.updateApp(args.appId, updateData); if (this.shouldOutputJson(flags)) { this.logJsonResult( @@ -101,7 +101,7 @@ export default class AppsUpdateCommand extends ControlBaseCommand { this.logSuccessMessage("App updated successfully.", flags); } catch (error) { this.fail(error, flags, "appUpdate", { - appId: args.id, + appId: args.appId, }); } } diff --git a/src/commands/bench/publisher.ts b/src/commands/bench/publisher.ts index 2a51c52bd..8ca3702c4 100644 --- a/src/commands/bench/publisher.ts +++ b/src/commands/bench/publisher.ts @@ -38,7 +38,7 @@ interface PublisherFlags { } interface PublisherArgs { - channel: string; + channelName: string; } // Interface for message payload @@ -54,7 +54,7 @@ interface BenchmarkPayload { export default class BenchPublisher extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name to publish to", required: true, }), @@ -162,7 +162,9 @@ export default class BenchPublisher extends AblyBaseCommand { }; try { - channel = client.channels.get(args.channel, { params: { rewind: "1" } }); + channel = client.channels.get(args.channelName, { + params: { rewind: "1" }, + }); // Set up channel state logging this.setupChannelStateLogging(channel, flags, { @@ -174,7 +176,7 @@ export default class BenchPublisher extends AblyBaseCommand { metrics, messageTracking, flags, - args.channel, + args.channelName, ); await this.enterPresence( @@ -496,7 +498,7 @@ export default class BenchPublisher extends AblyBaseCommand { const summaryData = { actualRateMsgsPerSec: avgRate, - channel: args.channel, + channel: args.channelName, echoLatencyAvgMs: avgEchoLatency, echoLatencyP50Ms: echoP50, echoLatencyP90Ms: echoP90, @@ -536,7 +538,7 @@ export default class BenchPublisher extends AblyBaseCommand { }); summaryTable.push( ["Test ID", testId], - ["Channel", args.channel], + ["Channel", args.channelName], ["Transport", flags.transport], ["Messages sent", `${metrics.messagesSent}/${messageCount}`], [ diff --git a/src/commands/bench/subscriber.ts b/src/commands/bench/subscriber.ts index eef51c658..ee88bf037 100644 --- a/src/commands/bench/subscriber.ts +++ b/src/commands/bench/subscriber.ts @@ -21,7 +21,7 @@ interface TestMetrics { export default class BenchSubscriber extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name to subscribe to", required: true, }), @@ -89,11 +89,11 @@ export default class BenchSubscriber extends AblyBaseCommand { }; try { - const channel = this.handleChannel(client, args.channel, flags); + const channel = this.handleChannel(client, args.channelName, flags); // Show initial status this.logProgress( - `Attaching to channel: ${formatResource(args.channel)}`, + `Attaching to channel: ${formatResource(args.channelName)}`, flags, ); @@ -108,13 +108,13 @@ export default class BenchSubscriber extends AblyBaseCommand { flags, "benchmark", "subscriberReady", - `Subscriber ready on channel: ${args.channel}`, - { channel: args.channel }, + `Subscriber ready on channel: ${args.channelName}`, + { channel: args.channelName }, ); // Show success message this.logSuccessMessage( - `Subscribed to channel: ${formatResource(args.channel)}. Waiting for benchmark messages.`, + `Subscribed to channel: ${formatResource(args.channelName)}. Waiting for benchmark messages.`, flags, ); diff --git a/src/commands/channels/annotations/delete.ts b/src/commands/channels/annotations/delete.ts index ddecea70b..0d4c8e216 100644 --- a/src/commands/channels/annotations/delete.ts +++ b/src/commands/channels/annotations/delete.ts @@ -11,15 +11,15 @@ import { formatResource } from "../../../utils/output.js"; export default class ChannelsAnnotationsDelete extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to remove annotation from", required: true, }), - type: Args.string({ + annotationType: Args.string({ description: "The annotation type (e.g., reactions:flag.v1, reactions:multiple.v1)", required: true, @@ -47,9 +47,9 @@ export default class ChannelsAnnotationsDelete extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsAnnotationsDelete); - const channelName = args.channel; - const serial = args.serial; - const type = args.type; + const channelName = args.channelName; + const serial = args.messageSerial; + const type = args.annotationType; let client: Ably.Realtime | null = null; diff --git a/src/commands/channels/annotations/get.ts b/src/commands/channels/annotations/get.ts index 3535e74e5..293cb9af8 100644 --- a/src/commands/channels/annotations/get.ts +++ b/src/commands/channels/annotations/get.ts @@ -16,11 +16,11 @@ import type { AnnotationDisplayFields } from "../../../utils/output.js"; export default class ChannelsAnnotationsGet extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to get annotations for", required: true, }), @@ -46,8 +46,8 @@ export default class ChannelsAnnotationsGet extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsAnnotationsGet); - const channelName = args.channel; - const serial = args.serial; + const channelName = args.channelName; + const serial = args.messageSerial; try { const rest = await this.createAblyRestClient(flags); diff --git a/src/commands/channels/annotations/publish.ts b/src/commands/channels/annotations/publish.ts index b729e83dd..d190e6b3b 100644 --- a/src/commands/channels/annotations/publish.ts +++ b/src/commands/channels/annotations/publish.ts @@ -11,15 +11,15 @@ import { formatResource } from "../../../utils/output.js"; export default class ChannelsAnnotationsPublish extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to annotate", required: true, }), - type: Args.string({ + annotationType: Args.string({ description: "The annotation type (e.g., reactions:flag.v1, reactions:multiple.v1)", required: true, @@ -58,9 +58,9 @@ export default class ChannelsAnnotationsPublish extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsAnnotationsPublish); - const channelName = args.channel; - const serial = args.serial; - const type = args.type; + const channelName = args.channelName; + const serial = args.messageSerial; + const type = args.annotationType; try { const summarization = extractSummarizationType(type); diff --git a/src/commands/channels/annotations/subscribe.ts b/src/commands/channels/annotations/subscribe.ts index 6133e010e..508a27bca 100644 --- a/src/commands/channels/annotations/subscribe.ts +++ b/src/commands/channels/annotations/subscribe.ts @@ -17,7 +17,7 @@ import type { AnnotationDisplayFields } from "../../../utils/output.js"; export default class ChannelsAnnotationsSubscribe extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name to subscribe to annotations on", required: true, }), @@ -47,7 +47,7 @@ export default class ChannelsAnnotationsSubscribe extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsAnnotationsSubscribe); - const channelName = args.channel; + const channelName = args.channelName; try { this.client = await this.createAblyRealtimeClient(flags); diff --git a/src/commands/channels/append.ts b/src/commands/channels/append.ts index 16538048a..f39ca5767 100644 --- a/src/commands/channels/append.ts +++ b/src/commands/channels/append.ts @@ -8,11 +8,11 @@ import { formatResource } from "../../utils/output.js"; export default class ChannelsAppend extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to append to", required: true, }), @@ -51,8 +51,8 @@ export default class ChannelsAppend extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsAppend); - const channelName = args.channel; - const serial = args.serial; + const channelName = args.channelName; + const serial = args.messageSerial; try { const rest = await this.createAblyRestClient(flags); diff --git a/src/commands/channels/delete.ts b/src/commands/channels/delete.ts index fff9412dc..8f170800c 100644 --- a/src/commands/channels/delete.ts +++ b/src/commands/channels/delete.ts @@ -7,11 +7,11 @@ import { formatResource } from "../../utils/output.js"; export default class ChannelsDelete extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to delete", required: true, }), @@ -36,8 +36,8 @@ export default class ChannelsDelete extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsDelete); - const channelName = args.channel; - const serial = args.serial; + const channelName = args.channelName; + const serial = args.messageSerial; try { const rest = await this.createAblyRestClient(flags); diff --git a/src/commands/channels/history.ts b/src/commands/channels/history.ts index 50845b9a6..bee38d77d 100644 --- a/src/commands/channels/history.ts +++ b/src/commands/channels/history.ts @@ -22,7 +22,7 @@ import { export default class ChannelsHistory extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel name to retrieve history for", required: true, }), @@ -62,7 +62,7 @@ export default class ChannelsHistory extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsHistory); - const channelName = args.channel; + const channelName = args.channelName; let client: Ably.Rest | null; try { diff --git a/src/commands/channels/inspect.ts b/src/commands/channels/inspect.ts index 0fb9fc493..ebe1542d5 100644 --- a/src/commands/channels/inspect.ts +++ b/src/commands/channels/inspect.ts @@ -6,7 +6,7 @@ import { formatResource } from "../../utils/output.js"; export default class ChannelsInspect extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The name of the channel to inspect in the Ably dashboard", required: true, }), @@ -52,7 +52,7 @@ export default class ChannelsInspect extends AblyBaseCommand { if (dashboardHost && !/^https?:\/\//i.test(dashboardHost)) { dashboardHost = `https://${dashboardHost}`; } - const url = `${dashboardHost}/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`; + const url = `${dashboardHost}/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channelName)}`; if (this.shouldOutputJson(flags)) { this.logJsonResult({ channel: { url } }, flags); diff --git a/src/commands/channels/occupancy/get.ts b/src/commands/channels/occupancy/get.ts index cfb358934..6506bba7e 100644 --- a/src/commands/channels/occupancy/get.ts +++ b/src/commands/channels/occupancy/get.ts @@ -18,7 +18,7 @@ interface OccupancyMetrics { export default class ChannelsOccupancyGet extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel name to get occupancy for", required: true, }), @@ -47,7 +47,7 @@ export default class ChannelsOccupancyGet extends AblyBaseCommand { return; } - const channelName = args.channel; + const channelName = args.channelName; // Use the REST API to get channel details with occupancy const channelDetails = await client.request( @@ -130,7 +130,7 @@ export default class ChannelsOccupancyGet extends AblyBaseCommand { } } catch (error) { this.fail(error, flags, "occupancyGet", { - channel: args.channel, + channel: args.channelName, }); } } diff --git a/src/commands/channels/occupancy/subscribe.ts b/src/commands/channels/occupancy/subscribe.ts index b8e46b8aa..d66346479 100644 --- a/src/commands/channels/occupancy/subscribe.ts +++ b/src/commands/channels/occupancy/subscribe.ts @@ -12,7 +12,7 @@ import { export default class ChannelsOccupancySubscribe extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel name to subscribe to occupancy events", required: true, }), @@ -43,7 +43,7 @@ export default class ChannelsOccupancySubscribe extends AblyBaseCommand { if (!this.client) return; const client = this.client; - const channelName = args.channel; + const channelName = args.channelName; // Get channel with occupancy option enabled const channel = client.channels.get(channelName, { @@ -147,7 +147,7 @@ export default class ChannelsOccupancySubscribe extends AblyBaseCommand { await this.waitAndTrackCleanup(flags, "occupancy", flags.duration); } catch (error) { this.fail(error, flags, "occupancySubscribe", { - channel: args.channel, + channel: args.channelName, }); } } diff --git a/src/commands/channels/presence/enter.ts b/src/commands/channels/presence/enter.ts index 8327f71d1..669a1f229 100644 --- a/src/commands/channels/presence/enter.ts +++ b/src/commands/channels/presence/enter.ts @@ -15,7 +15,7 @@ import { export default class ChannelsPresenceEnter extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel to enter presence on", required: true, }), @@ -64,7 +64,7 @@ export default class ChannelsPresenceEnter extends AblyBaseCommand { if (!this.client) return; const client = this.client; - const { channel: channelName } = args; + const { channelName } = args; // Parse data if provided let data: unknown = undefined; @@ -205,7 +205,7 @@ export default class ChannelsPresenceEnter extends AblyBaseCommand { await this.waitAndTrackCleanup(flags, "presence", flags.duration); } catch (error) { this.fail(error, flags, "presenceEnter", { - channel: args.channel, + channel: args.channelName, }); } } diff --git a/src/commands/channels/presence/get.ts b/src/commands/channels/presence/get.ts index 7ee8015ed..34050cf6f 100644 --- a/src/commands/channels/presence/get.ts +++ b/src/commands/channels/presence/get.ts @@ -20,7 +20,7 @@ import { export default class ChannelsPresenceGet extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel name to get presence members for", required: true, }), @@ -51,7 +51,7 @@ export default class ChannelsPresenceGet extends AblyBaseCommand { const client = await this.createAblyRestClient(flags); if (!client) return; - const channelName = args.channel; + const channelName = args.channelName; this.logProgress( `Fetching presence members for channel: ${formatResource(channelName)}`, @@ -148,7 +148,7 @@ export default class ChannelsPresenceGet extends AblyBaseCommand { } } catch (error) { this.fail(error, flags, "presenceGet", { - channel: args.channel, + channel: args.channelName, }); } } diff --git a/src/commands/channels/presence/subscribe.ts b/src/commands/channels/presence/subscribe.ts index dd44df544..918d90cab 100644 --- a/src/commands/channels/presence/subscribe.ts +++ b/src/commands/channels/presence/subscribe.ts @@ -11,7 +11,7 @@ import type { PresenceDisplayFields } from "../../../utils/output.js"; export default class ChannelsPresenceSubscribe extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "Channel name to subscribe to presence events", required: true, }), @@ -43,7 +43,7 @@ export default class ChannelsPresenceSubscribe extends AblyBaseCommand { if (!this.client) return; const client = this.client; - const channelName = args.channel; + const channelName = args.channelName; const channel = client.channels.get(channelName); @@ -129,7 +129,7 @@ export default class ChannelsPresenceSubscribe extends AblyBaseCommand { await this.waitAndTrackCleanup(flags, "presence", flags.duration); } catch (error) { this.fail(error, flags, "presenceSubscribe", { - channel: args.channel, + channel: args.channelName, }); } } diff --git a/src/commands/channels/publish.ts b/src/commands/channels/publish.ts index e05a4d701..ae865fbc3 100644 --- a/src/commands/channels/publish.ts +++ b/src/commands/channels/publish.ts @@ -11,7 +11,7 @@ import { formatResource } from "../../utils/output.js"; export default class ChannelsPublish extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name to publish to", required: true, }), @@ -119,15 +119,15 @@ export default class ChannelsPublish extends AblyBaseCommand { results, allSucceeded: errors === 0 && published === total, total, - channel: args.channel, + channel: args.channelName, }, }; const eventType = total > 1 ? "multiPublishComplete" : "singlePublishComplete"; const eventMessage = total > 1 - ? `Published ${total} messages to channel ${String(args.channel)}` - : `Published message to channel ${String(args.channel)}`; + ? `Published ${total} messages to channel ${String(args.channelName)}` + : `Published message to channel ${String(args.channelName)}`; this.logCliEvent(flags, "publish", eventType, eventMessage, finalResult); if (!this.shouldSuppressOutput(flags)) { @@ -135,12 +135,12 @@ export default class ChannelsPublish extends AblyBaseCommand { this.logJsonResult(finalResult, flags); } else if (total > 1) { this.logSuccessMessage( - `${published}/${total} messages published to channel: ${formatResource(args.channel as string)}${errors > 0 ? ` (${chalk.red(errors)} errors)` : ""}.`, + `${published}/${total} messages published to channel: ${formatResource(args.channelName as string)}${errors > 0 ? ` (${chalk.red(errors)} errors)` : ""}.`, flags, ); } else if (errors === 0) { this.logSuccessMessage( - `Message published to channel: ${formatResource(args.channel as string)}.`, + `Message published to channel: ${formatResource(args.channelName as string)}.`, flags, ); const rawSerial = results[0]?.serial; @@ -223,11 +223,11 @@ export default class ChannelsPublish extends AblyBaseCommand { flags, "publish", "messagePublished", - `Message ${messageIndex} published to channel ${String(args.channel)}`, + `Message ${messageIndex} published to channel ${String(args.channelName)}`, { index: messageIndex, message, - channel: args.channel, + channel: args.channelName, ...(serial === undefined ? {} : { serial }), }, ); @@ -236,7 +236,7 @@ export default class ChannelsPublish extends AblyBaseCommand { count > 1 // Only show individual success messages when publishing multiple messages ) { this.logSuccessMessage( - `Message ${messageIndex} published to channel: ${formatResource(args.channel as string)}.`, + `Message ${messageIndex} published to channel: ${formatResource(args.channelName as string)}.`, flags, ); } @@ -316,14 +316,14 @@ export default class ChannelsPublish extends AblyBaseCommand { "transportSelected", "Using Realtime transport", ); - const channel = client.channels.get(args.channel as string); + const channel = client.channels.get(args.channelName as string); channel.on((stateChange: Ably.ChannelStateChange) => { this.logCliEvent( flags, "channel", stateChange.current, - `Channel '${String(args.channel)}' state changed to ${stateChange.current}`, + `Channel '${String(args.channelName)}' state changed to ${stateChange.current}`, { reason: stateChange.reason }, ); }); @@ -347,7 +347,7 @@ export default class ChannelsPublish extends AblyBaseCommand { if (!rest) { return; } - const channel = rest.channels.get(args.channel as string); + const channel = rest.channels.get(args.channelName as string); this.logCliEvent( flags, diff --git a/src/commands/channels/subscribe.ts b/src/commands/channels/subscribe.ts index b7f43421a..2c7722b84 100644 --- a/src/commands/channels/subscribe.ts +++ b/src/commands/channels/subscribe.ts @@ -17,7 +17,7 @@ import type { MessageDisplayFields } from "../../utils/output.js"; export default class ChannelsSubscribe extends AblyBaseCommand { static override args = { - channels: Args.string({ + channelNames: Args.string({ description: "Channel name(s) to subscribe to", multiple: false, required: true, diff --git a/src/commands/channels/update.ts b/src/commands/channels/update.ts index f9e870270..6d2a0c4ab 100644 --- a/src/commands/channels/update.ts +++ b/src/commands/channels/update.ts @@ -8,11 +8,11 @@ import { formatResource } from "../../utils/output.js"; export default class ChannelsUpdate extends AblyBaseCommand { static override args = { - channel: Args.string({ + channelName: Args.string({ description: "The channel name", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to update", required: true, }), @@ -51,8 +51,8 @@ export default class ChannelsUpdate extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(ChannelsUpdate); - const channelName = args.channel; - const serial = args.serial; + const channelName = args.channelName; + const serial = args.messageSerial; try { const rest = await this.createAblyRestClient(flags); diff --git a/src/commands/integrations/delete.ts b/src/commands/integrations/delete.ts index 0fdbb219b..c9c8e0e82 100644 --- a/src/commands/integrations/delete.ts +++ b/src/commands/integrations/delete.ts @@ -7,7 +7,7 @@ import { promptForConfirmation } from "../../utils/prompt-confirmation.js"; export default class IntegrationsDeleteCommand extends ControlBaseCommand { static args = { - integrationId: Args.string({ + ruleId: Args.string({ description: "The integration ID to delete", required: true, }), @@ -39,7 +39,7 @@ export default class IntegrationsDeleteCommand extends ControlBaseCommand { try { const controlApi = this.createControlApi(flags); // Get integration details for confirmation - const integration = await controlApi.getRule(appId, args.integrationId); + const integration = await controlApi.getRule(appId, args.ruleId); // In JSON mode, require --force to prevent accidental destructive actions if (!flags.force && this.shouldOutputJson(flags)) { @@ -73,7 +73,7 @@ export default class IntegrationsDeleteCommand extends ControlBaseCommand { } } - await controlApi.deleteRule(appId, args.integrationId); + await controlApi.deleteRule(appId, args.ruleId); if (this.shouldOutputJson(flags)) { this.logJsonResult( diff --git a/src/commands/push/devices/get.ts b/src/commands/push/devices/get.ts index dc76b3d67..578253912 100644 --- a/src/commands/push/devices/get.ts +++ b/src/commands/push/devices/get.ts @@ -11,7 +11,7 @@ import { export default class PushDevicesGet extends AblyBaseCommand { static override args = { - "device-id": Args.string({ + deviceId: Args.string({ description: "The device ID to retrieve", required: true, }), @@ -30,7 +30,7 @@ export default class PushDevicesGet extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(PushDevicesGet); - const deviceId = args["device-id"]; + const deviceId = args.deviceId; try { const rest = await this.createAblyRestClient(flags as BaseFlags); diff --git a/src/commands/push/devices/remove.ts b/src/commands/push/devices/remove.ts index 227328e68..7354cc664 100644 --- a/src/commands/push/devices/remove.ts +++ b/src/commands/push/devices/remove.ts @@ -8,7 +8,7 @@ import { promptForConfirmation } from "../../../utils/prompt-confirmation.js"; export default class PushDevicesRemove extends AblyBaseCommand { static override args = { - "device-id": Args.string({ + deviceId: Args.string({ description: "The device ID to remove", required: true, }), @@ -29,7 +29,7 @@ export default class PushDevicesRemove extends AblyBaseCommand { async run(): Promise { const { args, flags } = await this.parse(PushDevicesRemove); - const deviceId = args["device-id"]; + const deviceId = args.deviceId; try { const rest = await this.createAblyRestClient(flags as BaseFlags); diff --git a/src/commands/rooms/messages/delete.ts b/src/commands/rooms/messages/delete.ts index f4d37ae68..a58734252 100644 --- a/src/commands/rooms/messages/delete.ts +++ b/src/commands/rooms/messages/delete.ts @@ -7,11 +7,11 @@ import { formatResource } from "../../../utils/output.js"; export default class MessagesDelete extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room containing the message to delete", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to delete", required: true, }), @@ -47,13 +47,13 @@ export default class MessagesDelete extends ChatBaseCommand { ); } - const room = await chatClient.rooms.get(args.room); + const room = await chatClient.rooms.get(args.roomName); this.logProgress( "Deleting message " + - formatResource(args.serial) + + formatResource(args.messageSerial) + " in room " + - formatResource(args.room), + formatResource(args.roomName), flags, ); @@ -66,26 +66,26 @@ export default class MessagesDelete extends ChatBaseCommand { flags, "roomMessageDelete", "deleting", - `Deleting message ${args.serial} from room ${args.room}`, - { room: args.room, serial: args.serial }, + `Deleting message ${args.messageSerial} from room ${args.roomName}`, + { room: args.roomName, serial: args.messageSerial }, ); - const result = await room.messages.delete(args.serial, details); + const result = await room.messages.delete(args.messageSerial, details); this.logCliEvent( flags, "roomMessageDelete", "messageDeleted", - `Message ${args.serial} deleted from room ${args.room}`, - { room: args.room, serial: args.serial }, + `Message ${args.messageSerial} deleted from room ${args.roomName}`, + { room: args.roomName, serial: args.messageSerial }, ); if (this.shouldOutputJson(flags)) { this.logJsonResult( { message: { - room: args.room, - serial: args.serial, + room: args.roomName, + serial: args.messageSerial, versionSerial: result.version.serial, }, }, @@ -96,13 +96,13 @@ export default class MessagesDelete extends ChatBaseCommand { } this.logSuccessMessage( - `Message ${formatResource(args.serial)} deleted from room ${formatResource(args.room)}.`, + `Message ${formatResource(args.messageSerial)} deleted from room ${formatResource(args.roomName)}.`, flags, ); } catch (error) { this.fail(error, flags, "roomMessageDelete", { - room: args.room, - serial: args.serial, + room: args.roomName, + serial: args.messageSerial, }); } } diff --git a/src/commands/rooms/messages/history.ts b/src/commands/rooms/messages/history.ts index efeaa55fe..b5167bc34 100644 --- a/src/commands/rooms/messages/history.ts +++ b/src/commands/rooms/messages/history.ts @@ -23,7 +23,7 @@ import { parseTimestamp } from "../../../utils/time.js"; export default class MessagesHistory extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room to get message history from", required: true, }), @@ -80,14 +80,14 @@ export default class MessagesHistory extends ChatBaseCommand { ); } - const room = await chatClient.rooms.get(args.room); + const room = await chatClient.rooms.get(args.roomName); if (!this.shouldSuppressOutput(flags)) { if (this.shouldOutputJson(flags)) { this.logJsonEvent( { limit: flags.limit, - room: args.room, + room: args.roomName, status: "fetching", }, flags, @@ -95,7 +95,7 @@ export default class MessagesHistory extends ChatBaseCommand { } this.logProgress( - `Fetching ${flags.limit} most recent messages from room ${formatResource(args.room)}`, + `Fetching ${flags.limit} most recent messages from room ${formatResource(args.roomName)}`, flags, ); } @@ -132,7 +132,7 @@ export default class MessagesHistory extends ChatBaseCommand { "--start must be earlier than or equal to --end", flags, "roomMessageHistory", - { room: args.room }, + { room: args.roomName }, ); } @@ -168,7 +168,7 @@ export default class MessagesHistory extends ChatBaseCommand { metadata: message.metadata, })), ...(next && { next }), - room: args.room, + room: args.roomName, }, flags, ); @@ -214,7 +214,7 @@ export default class MessagesHistory extends ChatBaseCommand { } } } catch (error) { - this.fail(error, flags, "roomMessageHistory", { room: args.room }); + this.fail(error, flags, "roomMessageHistory", { room: args.roomName }); } } } diff --git a/src/commands/rooms/messages/reactions/remove.ts b/src/commands/rooms/messages/reactions/remove.ts index e494e3b52..187b36b14 100644 --- a/src/commands/rooms/messages/reactions/remove.ts +++ b/src/commands/rooms/messages/reactions/remove.ts @@ -8,7 +8,7 @@ import { REACTION_TYPE_MAP } from "../../../../utils/chat-constants.js"; export default class MessagesReactionsRemove extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room where the message is located", required: true, }), @@ -43,7 +43,7 @@ export default class MessagesReactionsRemove extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(MessagesReactionsRemove); - const { room, messageSerial, reaction } = args; + const { roomName: room, messageSerial, reaction } = args; try { // Create Chat client diff --git a/src/commands/rooms/messages/reactions/send.ts b/src/commands/rooms/messages/reactions/send.ts index e55c9b242..e3de00c49 100644 --- a/src/commands/rooms/messages/reactions/send.ts +++ b/src/commands/rooms/messages/reactions/send.ts @@ -9,7 +9,7 @@ import { REACTION_TYPE_MAP } from "../../../../utils/chat-constants.js"; export default class MessagesReactionsSend extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room where the message is located", required: true, }), @@ -50,7 +50,7 @@ export default class MessagesReactionsSend extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(MessagesReactionsSend); - const { room, messageSerial, reaction } = args; + const { roomName: room, messageSerial, reaction } = args; try { // Validate count for Multiple type diff --git a/src/commands/rooms/messages/reactions/subscribe.ts b/src/commands/rooms/messages/reactions/subscribe.ts index 9751e7332..28ccbb02b 100644 --- a/src/commands/rooms/messages/reactions/subscribe.ts +++ b/src/commands/rooms/messages/reactions/subscribe.ts @@ -23,7 +23,7 @@ import { export default class MessagesReactionsSubscribe extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to subscribe to message reactions in", required: true, }), @@ -63,11 +63,11 @@ export default class MessagesReactionsSubscribe extends ChatBaseCommand { "Failed to initialize clients", flags, "roomMessageReactionSubscribe", - { room: args.room }, + { room: args.roomName }, ); } - const { room } = args; + const { roomName: room } = args; // Set up connection state logging this.setupConnectionStateLogging(this.chatClient.realtime, flags, { @@ -247,7 +247,7 @@ export default class MessagesReactionsSubscribe extends ChatBaseCommand { ]); } catch (error) { this.fail(error, flags, "roomMessageReactionSubscribe", { - room: args.room, + room: args.roomName, }); } } diff --git a/src/commands/rooms/messages/send.ts b/src/commands/rooms/messages/send.ts index 2eaf146f1..99bd59ca2 100644 --- a/src/commands/rooms/messages/send.ts +++ b/src/commands/rooms/messages/send.ts @@ -31,7 +31,7 @@ interface MessageResult { export default class MessagesSend extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room to send the message to", required: true, }), @@ -123,7 +123,7 @@ export default class MessagesSend extends ChatBaseCommand { ); } - const room = await this.chatClient.rooms.get(args.room); + const room = await this.chatClient.rooms.get(args.roomName); const count = flags.count; let { delay } = flags; @@ -207,7 +207,7 @@ export default class MessagesSend extends ChatBaseCommand { const result: MessageResult = { index: i + 1, message: messageToSend, - room: args.room, + room: args.roomName, success: true, }; results.push(result); @@ -225,7 +225,7 @@ export default class MessagesSend extends ChatBaseCommand { const result: MessageResult = { error: extractErrorInfo(error), index: i + 1, - room: args.room, + room: args.roomName, success: false, }; results.push(result); @@ -294,7 +294,7 @@ export default class MessagesSend extends ChatBaseCommand { } this.logSuccessMessage( - `${sentCount}/${count} messages sent to room ${formatResource(args.room)} (${errorCount} errors).`, + `${sentCount}/${count} messages sent to room ${formatResource(args.roomName)} (${errorCount} errors).`, flags, ); } @@ -319,7 +319,7 @@ export default class MessagesSend extends ChatBaseCommand { const sentMessage = await room.messages.send(messageToSend); const result: MessageResult = { message: messageToSend, - room: args.room, + room: args.roomName, serial: sentMessage.serial, success: true, }; @@ -337,7 +337,7 @@ export default class MessagesSend extends ChatBaseCommand { { message: { ...messageToSend, - room: args.room, + room: args.roomName, serial: sentMessage.serial, }, }, @@ -346,7 +346,7 @@ export default class MessagesSend extends ChatBaseCommand { } this.logSuccessMessage( - `Message sent to room ${formatResource(args.room)}.`, + `Message sent to room ${formatResource(args.roomName)}.`, flags, ); @@ -356,7 +356,7 @@ export default class MessagesSend extends ChatBaseCommand { } } catch (error) { this.fail(error, flags, "roomMessageSend", { - room: args.room, + room: args.roomName, }); } } diff --git a/src/commands/rooms/messages/subscribe.ts b/src/commands/rooms/messages/subscribe.ts index 9fb21a25f..0f6dd0c53 100644 --- a/src/commands/rooms/messages/subscribe.ts +++ b/src/commands/rooms/messages/subscribe.ts @@ -27,7 +27,7 @@ interface ChatMessage { export default class MessagesSubscribe extends ChatBaseCommand { static override args = { - rooms: Args.string({ + roomNames: Args.string({ description: "Room name(s) to subscribe to messages from", multiple: false, required: true, diff --git a/src/commands/rooms/messages/update.ts b/src/commands/rooms/messages/update.ts index 20c4d53d2..6201808f9 100644 --- a/src/commands/rooms/messages/update.ts +++ b/src/commands/rooms/messages/update.ts @@ -12,11 +12,11 @@ import { formatResource } from "../../../utils/output.js"; export default class MessagesUpdate extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room containing the message to update", required: true, }), - serial: Args.string({ + messageSerial: Args.string({ description: "The serial of the message to update", required: true, }), @@ -126,13 +126,13 @@ export default class MessagesUpdate extends ChatBaseCommand { ); } - const room = await chatClient.rooms.get(args.room); + const room = await chatClient.rooms.get(args.roomName); this.logProgress( "Updating message " + - formatResource(args.serial) + + formatResource(args.messageSerial) + " in room " + - formatResource(args.room), + formatResource(args.roomName), flags, ); @@ -152,12 +152,12 @@ export default class MessagesUpdate extends ChatBaseCommand { flags, "roomMessageUpdate", "updating", - `Updating message ${args.serial} in room ${args.room}`, - { room: args.room, serial: args.serial }, + `Updating message ${args.messageSerial} in room ${args.roomName}`, + { room: args.roomName, serial: args.messageSerial }, ); const result = await room.messages.update( - args.serial, + args.messageSerial, updateParams, details, ); @@ -166,16 +166,16 @@ export default class MessagesUpdate extends ChatBaseCommand { flags, "roomMessageUpdate", "messageUpdated", - `Message ${args.serial} updated in room ${args.room}`, - { room: args.room, serial: args.serial }, + `Message ${args.messageSerial} updated in room ${args.roomName}`, + { room: args.roomName, serial: args.messageSerial }, ); if (this.shouldOutputJson(flags)) { this.logJsonResult( { message: { - room: args.room, - serial: args.serial, + room: args.roomName, + serial: args.messageSerial, updatedText: result.text, versionSerial: result.version.serial, }, @@ -187,13 +187,13 @@ export default class MessagesUpdate extends ChatBaseCommand { } this.logSuccessMessage( - `Message ${formatResource(args.serial)} updated in room ${formatResource(args.room)}.`, + `Message ${formatResource(args.messageSerial)} updated in room ${formatResource(args.roomName)}.`, flags, ); } catch (error) { this.fail(error, flags, "roomMessageUpdate", { - room: args.room, - serial: args.serial, + room: args.roomName, + serial: args.messageSerial, }); } } diff --git a/src/commands/rooms/occupancy/get.ts b/src/commands/rooms/occupancy/get.ts index ef82ec172..4e16b5955 100644 --- a/src/commands/rooms/occupancy/get.ts +++ b/src/commands/rooms/occupancy/get.ts @@ -6,7 +6,7 @@ import { formatLabel, formatResource } from "../../../utils/output.js"; export default class RoomsOccupancyGet extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to get occupancy for", required: true, }), @@ -43,7 +43,7 @@ export default class RoomsOccupancyGet extends ChatBaseCommand { ); } - const { room: roomName } = args; + const { roomName } = args; this.room = await this.chatClient.rooms.get(roomName); @@ -70,7 +70,7 @@ export default class RoomsOccupancyGet extends ChatBaseCommand { ); } } catch (error) { - this.fail(error, flags, "roomOccupancyGet", { room: args.room }); + this.fail(error, flags, "roomOccupancyGet", { room: args.roomName }); } } } diff --git a/src/commands/rooms/occupancy/subscribe.ts b/src/commands/rooms/occupancy/subscribe.ts index f7e42ca26..b7395096a 100644 --- a/src/commands/rooms/occupancy/subscribe.ts +++ b/src/commands/rooms/occupancy/subscribe.ts @@ -16,7 +16,7 @@ export interface OccupancyMetrics { export default class RoomsOccupancySubscribe extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to subscribe to occupancy for", required: true, }), @@ -42,7 +42,7 @@ export default class RoomsOccupancySubscribe extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(RoomsOccupancySubscribe); - this.roomName = args.room; // Store for cleanup + this.roomName = args.roomName; // Store for cleanup try { this.logCliEvent( diff --git a/src/commands/rooms/presence/enter.ts b/src/commands/rooms/presence/enter.ts index ce57618e5..f8af8dedf 100644 --- a/src/commands/rooms/presence/enter.ts +++ b/src/commands/rooms/presence/enter.ts @@ -15,7 +15,7 @@ import { export default class RoomsPresenceEnter extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to enter presence on", required: true, }), @@ -61,7 +61,7 @@ export default class RoomsPresenceEnter extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(RoomsPresenceEnter); - this.roomName = args.room; + this.roomName = args.roomName; if (flags.data) { const parsed = this.parseJsonFlag(flags.data, "data", flags); diff --git a/src/commands/rooms/presence/get.ts b/src/commands/rooms/presence/get.ts index 0a84305eb..d62f726b4 100644 --- a/src/commands/rooms/presence/get.ts +++ b/src/commands/rooms/presence/get.ts @@ -24,7 +24,7 @@ const chatChannelName = (roomName: string) => `${roomName}::$chat`; export default class RoomsPresenceGet extends AblyBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to get presence members for", required: true, }), @@ -56,7 +56,7 @@ export default class RoomsPresenceGet extends AblyBaseCommand { const client = await this.createAblyRestClient(flags); if (!client) return; - const { room: roomName } = args; + const { roomName } = args; const channelName = chatChannelName(roomName); this.logProgress( @@ -153,7 +153,7 @@ export default class RoomsPresenceGet extends AblyBaseCommand { } } catch (error) { this.fail(error, flags, "roomPresenceGet", { - room: args.room, + room: args.roomName, }); } } diff --git a/src/commands/rooms/presence/subscribe.ts b/src/commands/rooms/presence/subscribe.ts index 33950df24..b3af3d3d2 100644 --- a/src/commands/rooms/presence/subscribe.ts +++ b/src/commands/rooms/presence/subscribe.ts @@ -15,7 +15,7 @@ import { export default class RoomsPresenceSubscribe extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to subscribe to presence for", required: true, }), @@ -41,7 +41,7 @@ export default class RoomsPresenceSubscribe extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(RoomsPresenceSubscribe); - this.roomName = args.room; + this.roomName = args.roomName; try { // Show a progress signal early so E2E harnesses know the command is running diff --git a/src/commands/rooms/reactions/send.ts b/src/commands/rooms/reactions/send.ts index 7b192866e..44f4e912b 100644 --- a/src/commands/rooms/reactions/send.ts +++ b/src/commands/rooms/reactions/send.ts @@ -8,7 +8,7 @@ import { formatResource } from "../../../utils/output.js"; export default class RoomsReactionsSend extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room to send the reaction to", required: true, }), @@ -42,7 +42,7 @@ export default class RoomsReactionsSend extends ChatBaseCommand { async run(): Promise { const { args, flags } = await this.parse(RoomsReactionsSend); - const { room: roomName, emoji } = args; + const { roomName, emoji } = args; try { // Parse metadata if provided diff --git a/src/commands/rooms/reactions/subscribe.ts b/src/commands/rooms/reactions/subscribe.ts index 88bb4cbea..7ade0bd0c 100644 --- a/src/commands/rooms/reactions/subscribe.ts +++ b/src/commands/rooms/reactions/subscribe.ts @@ -13,7 +13,7 @@ import { export default class RoomsReactionsSubscribe extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "Room to subscribe to reactions in", required: true, }), @@ -50,7 +50,7 @@ export default class RoomsReactionsSubscribe extends ChatBaseCommand { ); } - const { room: roomName } = args; + const { roomName } = args; // Set up connection state logging this.setupConnectionStateLogging(this.chatClient.realtime, flags, { @@ -167,7 +167,7 @@ export default class RoomsReactionsSubscribe extends ChatBaseCommand { failurePromise, ]); } catch (error) { - this.fail(error, flags, "roomReactionSubscribe", { room: args.room }); + this.fail(error, flags, "roomReactionSubscribe", { room: args.roomName }); } } } diff --git a/src/commands/rooms/typing/keystroke.ts b/src/commands/rooms/typing/keystroke.ts index 6d48348af..87152739e 100644 --- a/src/commands/rooms/typing/keystroke.ts +++ b/src/commands/rooms/typing/keystroke.ts @@ -16,7 +16,7 @@ const KEYSTROKE_INTERVAL = 450; // ms export default class TypingKeystroke extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room to start typing in", required: true, }), @@ -70,7 +70,7 @@ export default class TypingKeystroke extends ChatBaseCommand { ); } - const { room: roomName } = args; + const { roomName } = args; // Set up connection state logging this.setupConnectionStateLogging(this.chatClient.realtime, flags, { @@ -173,7 +173,7 @@ export default class TypingKeystroke extends ChatBaseCommand { failurePromise, ]); } catch (error) { - this.fail(error, flags, "roomTypingKeystroke", { room: args.room }); + this.fail(error, flags, "roomTypingKeystroke", { room: args.roomName }); } } } diff --git a/src/commands/rooms/typing/subscribe.ts b/src/commands/rooms/typing/subscribe.ts index b53ae8400..6f1a1e082 100644 --- a/src/commands/rooms/typing/subscribe.ts +++ b/src/commands/rooms/typing/subscribe.ts @@ -8,7 +8,7 @@ import { formatResource } from "../../../utils/output.js"; export default class TypingSubscribe extends ChatBaseCommand { static override args = { - room: Args.string({ + roomName: Args.string({ description: "The room to subscribe to typing indicators from", required: true, }), @@ -46,7 +46,7 @@ export default class TypingSubscribe extends ChatBaseCommand { ); } - const { room: roomName } = args; + const { roomName } = args; // Set up connection state logging this.setupConnectionStateLogging(this.chatClient.realtime, flags, { @@ -162,7 +162,7 @@ export default class TypingSubscribe extends ChatBaseCommand { failurePromise, ]); } catch (error) { - this.fail(error, flags, "roomTypingSubscribe", { room: args.room }); + this.fail(error, flags, "roomTypingSubscribe", { room: args.roomName }); } } } diff --git a/src/commands/spaces/create.ts b/src/commands/spaces/create.ts index 52c006de4..3c990669d 100644 --- a/src/commands/spaces/create.ts +++ b/src/commands/spaces/create.ts @@ -6,7 +6,7 @@ import { formatResource } from "../../utils/output.js"; export default class SpacesCreate extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to initialize", required: true, }), @@ -27,7 +27,7 @@ export default class SpacesCreate extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesCreate); - const spaceName = args.space_name; + const spaceName = args.spaceName; try { this.logProgress( diff --git a/src/commands/spaces/cursors/get.ts b/src/commands/spaces/cursors/get.ts index f3177bf94..843a1c4df 100644 --- a/src/commands/spaces/cursors/get.ts +++ b/src/commands/spaces/cursors/get.ts @@ -16,7 +16,7 @@ import { export default class SpacesCursorsGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to get cursors from", required: true, }), @@ -36,7 +36,7 @@ export default class SpacesCursorsGet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesCursorsGet); - const { space_name: spaceName } = args; + const { spaceName } = args; try { await this.initializeSpace(flags, spaceName, { diff --git a/src/commands/spaces/cursors/set.ts b/src/commands/spaces/cursors/set.ts index fa353f209..72339e28a 100644 --- a/src/commands/spaces/cursors/set.ts +++ b/src/commands/spaces/cursors/set.ts @@ -7,7 +7,7 @@ import { formatResource, formatLabel } from "../../../utils/output.js"; export default class SpacesCursorsSet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to set cursor in", required: true, }), @@ -62,7 +62,7 @@ export default class SpacesCursorsSet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesCursorsSet); - const { space_name: spaceName } = args; + const { spaceName } = args; try { // Validate and parse cursor data - either x/y flags or --data JSON diff --git a/src/commands/spaces/cursors/subscribe.ts b/src/commands/spaces/cursors/subscribe.ts index c7d6b65e6..ffc0b05cd 100644 --- a/src/commands/spaces/cursors/subscribe.ts +++ b/src/commands/spaces/cursors/subscribe.ts @@ -10,7 +10,7 @@ import { export default class SpacesCursorsSubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to subscribe to cursors for", required: true, }), @@ -35,7 +35,7 @@ export default class SpacesCursorsSubscribe extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesCursorsSubscribe); - const { space_name: spaceName } = args; + const { spaceName } = args; try { this.logProgress("Subscribing to cursor updates", flags); diff --git a/src/commands/spaces/get.ts b/src/commands/spaces/get.ts index c3421cd19..2514fa7ac 100644 --- a/src/commands/spaces/get.ts +++ b/src/commands/spaces/get.ts @@ -45,7 +45,7 @@ interface PresenceItem { export default class SpacesGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to get", required: true, }), @@ -65,7 +65,7 @@ export default class SpacesGet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesGet); - const spaceName = args.space_name; + const spaceName = args.spaceName; try { this.logProgress( diff --git a/src/commands/spaces/locations/get.ts b/src/commands/spaces/locations/get.ts index 474d1ef89..03dd032f9 100644 --- a/src/commands/spaces/locations/get.ts +++ b/src/commands/spaces/locations/get.ts @@ -13,7 +13,7 @@ import type { LocationEntry } from "../../../utils/spaces-output.js"; export default class SpacesLocationsGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to get locations from", required: true, }), @@ -33,7 +33,7 @@ export default class SpacesLocationsGet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocationsGet); - const { space_name: spaceName } = args; + const { spaceName } = args; try { await this.initializeSpace(flags, spaceName, { diff --git a/src/commands/spaces/locations/set.ts b/src/commands/spaces/locations/set.ts index c46120e61..ef8721949 100644 --- a/src/commands/spaces/locations/set.ts +++ b/src/commands/spaces/locations/set.ts @@ -10,7 +10,7 @@ import { export default class SpacesLocationsSet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to set location in", required: true, }), @@ -36,7 +36,7 @@ export default class SpacesLocationsSet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocationsSet); - const { space_name: spaceName } = args; + const { spaceName } = args; const location = this.parseJsonFlag(flags.location, "location", flags); diff --git a/src/commands/spaces/locations/subscribe.ts b/src/commands/spaces/locations/subscribe.ts index 1c68bf3e5..2005bc0d4 100644 --- a/src/commands/spaces/locations/subscribe.ts +++ b/src/commands/spaces/locations/subscribe.ts @@ -8,7 +8,7 @@ import { formatLocationUpdateBlock } from "../../../utils/spaces-output.js"; export default class SpacesLocationsSubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to subscribe to locations for", required: true, }), @@ -32,7 +32,7 @@ export default class SpacesLocationsSubscribe extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocationsSubscribe); - const { space_name: spaceName } = args; + const { spaceName } = args; try { this.logProgress("Subscribing to location updates", flags); diff --git a/src/commands/spaces/locks/acquire.ts b/src/commands/spaces/locks/acquire.ts index 8e7599d54..9af351e4f 100644 --- a/src/commands/spaces/locks/acquire.ts +++ b/src/commands/spaces/locks/acquire.ts @@ -12,7 +12,7 @@ import { export default class SpacesLocksAcquire extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to acquire lock in", required: true, }), @@ -67,7 +67,7 @@ export default class SpacesLocksAcquire extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocksAcquire); - const { space_name: spaceName } = args; + const { spaceName } = args; this.lockId = args.lockId; const { lockId } = this; diff --git a/src/commands/spaces/locks/get.ts b/src/commands/spaces/locks/get.ts index 4965eba00..22d8ce89d 100644 --- a/src/commands/spaces/locks/get.ts +++ b/src/commands/spaces/locks/get.ts @@ -16,7 +16,7 @@ import { export default class SpacesLocksGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to get locks from", required: true, }), @@ -43,7 +43,7 @@ export default class SpacesLocksGet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocksGet); - const { space_name: spaceName, lockId } = args; + const { spaceName, lockId } = args; try { await this.initializeSpace(flags, spaceName, { diff --git a/src/commands/spaces/locks/subscribe.ts b/src/commands/spaces/locks/subscribe.ts index 4a1cf7458..788e5061e 100644 --- a/src/commands/spaces/locks/subscribe.ts +++ b/src/commands/spaces/locks/subscribe.ts @@ -14,7 +14,7 @@ import { export default class SpacesLocksSubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to subscribe to locks for", required: true, }), @@ -39,7 +39,7 @@ export default class SpacesLocksSubscribe extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesLocksSubscribe); - const { space_name: spaceName } = args; + const { spaceName } = args; try { this.logProgress("Subscribing to lock events", flags); diff --git a/src/commands/spaces/members/enter.ts b/src/commands/spaces/members/enter.ts index dd6f9df11..9f44a8b66 100644 --- a/src/commands/spaces/members/enter.ts +++ b/src/commands/spaces/members/enter.ts @@ -12,7 +12,7 @@ import { formatMemberOutput } from "../../../utils/spaces-output.js"; export default class SpacesMembersEnter extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to enter", required: true, }), @@ -41,7 +41,7 @@ export default class SpacesMembersEnter extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesMembersEnter); - const { space_name: spaceName } = args; + const { spaceName } = args; try { this.logProgress("Entering space", flags); diff --git a/src/commands/spaces/members/get.ts b/src/commands/spaces/members/get.ts index 18581a829..3921d5191 100644 --- a/src/commands/spaces/members/get.ts +++ b/src/commands/spaces/members/get.ts @@ -16,7 +16,7 @@ import { export default class SpacesMembersGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to get members from", required: true, }), @@ -36,7 +36,7 @@ export default class SpacesMembersGet extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesMembersGet); - const { space_name: spaceName } = args; + const { spaceName } = args; try { await this.initializeSpace(flags, spaceName, { diff --git a/src/commands/spaces/members/subscribe.ts b/src/commands/spaces/members/subscribe.ts index 978a80921..a26c6ccdd 100644 --- a/src/commands/spaces/members/subscribe.ts +++ b/src/commands/spaces/members/subscribe.ts @@ -14,7 +14,7 @@ import { export default class SpacesMembersSubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to subscribe to members for", required: true, }), @@ -38,7 +38,7 @@ export default class SpacesMembersSubscribe extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesMembersSubscribe); - const { space_name: spaceName } = args; + const { spaceName } = args; // Keep track of the last event we've seen for each client to avoid duplicates const lastSeenEvents = new Map< diff --git a/src/commands/spaces/occupancy/get.ts b/src/commands/spaces/occupancy/get.ts index be59bca0f..3135c885e 100644 --- a/src/commands/spaces/occupancy/get.ts +++ b/src/commands/spaces/occupancy/get.ts @@ -14,7 +14,7 @@ interface OccupancyMetrics { export default class SpacesOccupancyGet extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Space name to get occupancy for", required: true, }), @@ -39,7 +39,7 @@ export default class SpacesOccupancyGet extends SpacesBaseCommand { const client = await this.createAblyRestClient(flags); if (!client) return; - const spaceName = args.space_name; + const spaceName = args.spaceName; const channelName = `${spaceName}${SPACE_CHANNEL_TAG}`; const channelDetails = await client.request( @@ -99,7 +99,7 @@ export default class SpacesOccupancyGet extends SpacesBaseCommand { } } catch (error) { this.fail(error, flags, "spacesOccupancyGet", { - spaceName: args.space_name, + spaceName: args.spaceName, }); } } diff --git a/src/commands/spaces/occupancy/subscribe.ts b/src/commands/spaces/occupancy/subscribe.ts index 4a753fe97..5e3839f23 100644 --- a/src/commands/spaces/occupancy/subscribe.ts +++ b/src/commands/spaces/occupancy/subscribe.ts @@ -15,7 +15,7 @@ const SPACE_CHANNEL_TAG = "::$space"; export default class SpacesOccupancySubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Space name to subscribe to occupancy events", required: true, }), @@ -43,7 +43,7 @@ export default class SpacesOccupancySubscribe extends SpacesBaseCommand { this.client = await this.createAblyRealtimeClient(flags); if (!this.client) return; - const spaceName = args.space_name; + const spaceName = args.spaceName; const channelName = `${spaceName}${SPACE_CHANNEL_TAG}`; const occupancyEventName = "[meta]occupancy"; @@ -144,7 +144,7 @@ export default class SpacesOccupancySubscribe extends SpacesBaseCommand { await this.waitAndTrackCleanup(flags, "spacesOccupancy", flags.duration); } catch (error) { this.fail(error, flags, "spacesOccupancySubscribe", { - spaceName: args.space_name, + spaceName: args.spaceName, }); } } diff --git a/src/commands/spaces/subscribe.ts b/src/commands/spaces/subscribe.ts index 51cd61f88..855d81081 100644 --- a/src/commands/spaces/subscribe.ts +++ b/src/commands/spaces/subscribe.ts @@ -18,7 +18,7 @@ import { export default class SpacesSubscribe extends SpacesBaseCommand { static override args = { - space_name: Args.string({ + spaceName: Args.string({ description: "Name of the space to subscribe to", required: true, }), @@ -42,7 +42,7 @@ export default class SpacesSubscribe extends SpacesBaseCommand { async run(): Promise { const { args, flags } = await this.parse(SpacesSubscribe); - const { space_name: spaceName } = args; + const { spaceName } = args; // Keep track of the last event we've seen for each client to avoid duplicates const lastSeenEvents = new Map< diff --git a/src/commands/stats/app.ts b/src/commands/stats/app.ts index 3ae9bc1c7..c7d276a0d 100644 --- a/src/commands/stats/app.ts +++ b/src/commands/stats/app.ts @@ -7,7 +7,7 @@ import { formatResource } from "../../utils/output.js"; export default class StatsAppCommand extends StatsBaseCommand { static args = { - id: Args.string({ + appId: Args.string({ description: "App ID to get stats for (uses default app if not provided)", required: false, }), @@ -49,7 +49,7 @@ export default class StatsAppCommand extends StatsBaseCommand { async run(): Promise { const { args, flags } = await this.parse(StatsAppCommand); - this.appId = args.id || this.configManager.getCurrentAppId() || ""; + this.appId = args.appId || this.configManager.getCurrentAppId() || ""; if (!this.appId) { this.fail( 'No app ID provided and no default app selected. Please specify an app ID or select a default app with "ably apps switch".', diff --git a/src/help.ts b/src/help.ts index 1b58c58e0..1ea4d1835 100644 --- a/src/help.ts +++ b/src/help.ts @@ -9,6 +9,11 @@ import { import { displayLogo } from "./utils/logo.js"; import { formatReleaseStatus } from "./utils/version.js"; +/** Convert camelCase arg name to snake_case so oclif's toUpperCase() produces UPPER_SNAKE_CASE */ +function camelToSnake(name: string): string { + return name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); +} + import { WEB_CLI_RESTRICTED_COMMANDS, WEB_CLI_ANONYMOUS_RESTRICTED_COMMANDS, @@ -390,8 +395,23 @@ export default class CustomHelp extends Help { // Capture the original colon-separated command ID before super.formatCommand // mutates it (oclif replaces ":" with the topicSeparator, which is " ") const originalCommandId = command.id; - // Use super's formatCommand - output = super.formatCommand(command); + + // Temporarily patch arg names: camelCase → snake_case + // so oclif's toUpperCase() produces UPPER_SNAKE_CASE (e.g., lockId → LOCK_ID) + const originalArgNames: { arg: { name: string }; name: string }[] = []; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- mock/test commands may have undefined args + for (const arg of Object.values(command.args ?? {})) { + originalArgNames.push({ arg, name: arg.name }); + arg.name = camelToSnake(arg.name); + } + + try { + output = super.formatCommand(command); + } finally { + for (const { arg, name } of originalArgNames) { + arg.name = name; + } + } // In interactive mode, remove the 'ably' prefix from usage examples if (process.env.ABLY_INTERACTIVE_MODE === "true") { diff --git a/test/unit/commands/spaces/spaces.test.ts b/test/unit/commands/spaces/spaces.test.ts index 0905cf233..d173a0019 100644 --- a/test/unit/commands/spaces/spaces.test.ts +++ b/test/unit/commands/spaces/spaces.test.ts @@ -209,7 +209,7 @@ describe("spaces commands", () => { expect(stdout).toContain("Acquire a lock"); expect(stdout).toContain("USAGE"); expect(stdout).toContain("SPACE_NAME"); - expect(stdout).toContain("LOCKID"); + expect(stdout).toContain("LOCK_ID"); }); it("should acquire lock with --data flag", async () => { From 75704a198df1d5c0628230e206b6db3c22973ad9 Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Fri, 17 Apr 2026 16:46:28 +0530 Subject: [PATCH 2/3] Updated `generate-doc` to create commands with SNAKE_CASE args - Added separate hook to apply camelCase to snake_case transformation - Simplified generate-doc to re-use `doc-template.md` --- package.json | 5 +++-- scripts/doc-template.md | 6 ++++++ src/hooks/init/patch-arg-names.ts | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 scripts/doc-template.md create mode 100644 src/hooks/init/patch-arg-names.ts diff --git a/package.json b/package.json index 392c34e29..8e0868ba9 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "prepare": "[ -d .git ] && [ -d .githooks ] && git config core.hooksPath .githooks || true; pnpm run build && CI=true ABLY_INTERACTIVE=false oclif manifest", "postinstall": "[ \"$CI\" = \"true\" ] || (test -f ./dist/scripts/postinstall-welcome.js && node ./dist/scripts/postinstall-welcome.js || echo \"Skipping welcome script (not found)\")", "preversion": "pnpm run prepare", - "generate-doc": "rm -f OCLIF_AUTOGENERATED_DOC.md && printf '\\n\\n\\n\\n\\n\\n' > OCLIF_AUTOGENERATED_DOC.md && (GENERATING_DOC=true NO_COLOR=1 oclif readme --readme-path OCLIF_AUTOGENERATED_DOC.md)", + "generate-doc": "cp scripts/doc-template.md OCLIF_AUTOGENERATED_DOC.md && GENERATING_DOC=true NO_COLOR=1 oclif readme --readme-path OCLIF_AUTOGENERATED_DOC.md", "validate": "./scripts/pre-push-validation.sh", "pre-commit": "pnpm validate", "ai-init": "echo 'AI Assistant Instructions:' && cat .claude/CLAUDE.md", @@ -78,7 +78,8 @@ "hooks": { "init": [ "./dist/src/hooks/init/alias-command", - "./dist/src/hooks/init/version-flag" + "./dist/src/hooks/init/version-flag", + "./dist/src/hooks/init/patch-arg-names" ], "command_not_found": "./dist/src/hooks/command_not_found/did-you-mean" }, diff --git a/scripts/doc-template.md b/scripts/doc-template.md new file mode 100644 index 000000000..2807f07a3 --- /dev/null +++ b/scripts/doc-template.md @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/hooks/init/patch-arg-names.ts b/src/hooks/init/patch-arg-names.ts new file mode 100644 index 000000000..0de04e7a2 --- /dev/null +++ b/src/hooks/init/patch-arg-names.ts @@ -0,0 +1,23 @@ +import { Hook } from "@oclif/core"; + +/** + * When generating docs (GENERATING_DOC=true), patch camelCase arg names to + * snake_case so oclif's toUpperCase() produces UPPER_SNAKE_CASE in headings/TOC. + * + * This complements the same patch in CustomHelp.formatCommand() (src/help.ts), + * which only covers the help body. The readme generator's commandUsage() has its + * own toUpperCase() call that runs before formatCommand, so we patch here — in + * the init hook — to cover all code paths. + */ +// eslint-disable-next-line @typescript-eslint/require-await -- oclif Hook type requires async +const hook: Hook<"init"> = async function ({ config }) { + if (process.env.GENERATING_DOC !== "true") return; + + for (const command of config.commands) { + for (const arg of Object.values(command.args)) { + arg.name = arg.name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); + } + } +}; + +export default hook; From 895f41cfb1ace002f694e0c75123c992875da68d Mon Sep 17 00:00:00 2001 From: sacOO7 Date: Mon, 20 Apr 2026 16:37:17 +0530 Subject: [PATCH 3/3] Refactored integrations get, update and delete commands --- src/commands/integrations/delete.ts | 6 +++--- src/commands/integrations/get.ts | 6 +++--- src/commands/integrations/update.ts | 8 ++++---- src/help.ts | 2 +- src/hooks/init/patch-arg-names.ts | 4 +++- test/unit/commands/integrations/delete.test.ts | 4 ++-- test/unit/commands/integrations/get.test.ts | 4 ++-- test/unit/commands/integrations/update.test.ts | 4 ++-- 8 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/commands/integrations/delete.ts b/src/commands/integrations/delete.ts index c9c8e0e82..0fdbb219b 100644 --- a/src/commands/integrations/delete.ts +++ b/src/commands/integrations/delete.ts @@ -7,7 +7,7 @@ import { promptForConfirmation } from "../../utils/prompt-confirmation.js"; export default class IntegrationsDeleteCommand extends ControlBaseCommand { static args = { - ruleId: Args.string({ + integrationId: Args.string({ description: "The integration ID to delete", required: true, }), @@ -39,7 +39,7 @@ export default class IntegrationsDeleteCommand extends ControlBaseCommand { try { const controlApi = this.createControlApi(flags); // Get integration details for confirmation - const integration = await controlApi.getRule(appId, args.ruleId); + const integration = await controlApi.getRule(appId, args.integrationId); // In JSON mode, require --force to prevent accidental destructive actions if (!flags.force && this.shouldOutputJson(flags)) { @@ -73,7 +73,7 @@ export default class IntegrationsDeleteCommand extends ControlBaseCommand { } } - await controlApi.deleteRule(appId, args.ruleId); + await controlApi.deleteRule(appId, args.integrationId); if (this.shouldOutputJson(flags)) { this.logJsonResult( diff --git a/src/commands/integrations/get.ts b/src/commands/integrations/get.ts index 9ac124a38..222288b88 100644 --- a/src/commands/integrations/get.ts +++ b/src/commands/integrations/get.ts @@ -5,8 +5,8 @@ import { formatHeading, formatLabel } from "../../utils/output.js"; export default class IntegrationsGetCommand extends ControlBaseCommand { static args = { - ruleId: Args.string({ - description: "The rule ID to get", + integrationId: Args.string({ + description: "The integration ID to get", required: true, }), }; @@ -38,7 +38,7 @@ export default class IntegrationsGetCommand extends ControlBaseCommand { try { const controlApi = this.createControlApi(flags); - const rule = await controlApi.getRule(appId, args.ruleId); + const rule = await controlApi.getRule(appId, args.integrationId); if (this.shouldOutputJson(flags)) { const ruleClone = structuredClone(rule) as unknown as Record< diff --git a/src/commands/integrations/update.ts b/src/commands/integrations/update.ts index 2970824e2..103512c70 100644 --- a/src/commands/integrations/update.ts +++ b/src/commands/integrations/update.ts @@ -14,8 +14,8 @@ interface PartialRuleData { export default class IntegrationsUpdateCommand extends ControlBaseCommand { static args = { - ruleId: Args.string({ - description: "The rule ID to update", + integrationId: Args.string({ + description: "The integration ID to update", required: true, }), }; @@ -70,7 +70,7 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand { try { const controlApi = this.createControlApi(flags); // Get current rule to preserve existing fields - const existingRule = await controlApi.getRule(appId, args.ruleId); + const existingRule = await controlApi.getRule(appId, args.integrationId); // Prepare update data - explicitly typed const updatePayload: Partial = { @@ -105,7 +105,7 @@ export default class IntegrationsUpdateCommand extends ControlBaseCommand { const updatedRule = await controlApi.updateRule( appId, - args.ruleId, + args.integrationId, updatePayload, ); diff --git a/src/help.ts b/src/help.ts index 1ea4d1835..a56e16baa 100644 --- a/src/help.ts +++ b/src/help.ts @@ -10,7 +10,7 @@ import { displayLogo } from "./utils/logo.js"; import { formatReleaseStatus } from "./utils/version.js"; /** Convert camelCase arg name to snake_case so oclif's toUpperCase() produces UPPER_SNAKE_CASE */ -function camelToSnake(name: string): string { +export function camelToSnake(name: string): string { return name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); } diff --git a/src/hooks/init/patch-arg-names.ts b/src/hooks/init/patch-arg-names.ts index 0de04e7a2..128018c13 100644 --- a/src/hooks/init/patch-arg-names.ts +++ b/src/hooks/init/patch-arg-names.ts @@ -1,5 +1,7 @@ import { Hook } from "@oclif/core"; +import { camelToSnake } from "../../help.js"; + /** * When generating docs (GENERATING_DOC=true), patch camelCase arg names to * snake_case so oclif's toUpperCase() produces UPPER_SNAKE_CASE in headings/TOC. @@ -15,7 +17,7 @@ const hook: Hook<"init"> = async function ({ config }) { for (const command of config.commands) { for (const arg of Object.values(command.args)) { - arg.name = arg.name.replaceAll(/([a-z])([A-Z])/g, "$1_$2").toLowerCase(); + arg.name = camelToSnake(arg.name); } } }; diff --git a/test/unit/commands/integrations/delete.test.ts b/test/unit/commands/integrations/delete.test.ts index 6f0f44ecf..b4dc804c4 100644 --- a/test/unit/commands/integrations/delete.test.ts +++ b/test/unit/commands/integrations/delete.test.ts @@ -112,7 +112,7 @@ describe("integrations:delete command", () => { }, }); - it("should require ruleId argument", async () => { + it("should require integrationId argument", async () => { const { error } = await runCommand( ["integrations:delete", "--force"], import.meta.url, @@ -278,6 +278,6 @@ describe("integrations:delete command", () => { standardHelpTests("integrations:delete", import.meta.url); standardArgValidationTests("integrations:delete", import.meta.url, { - requiredArgs: ["ruleId"], + requiredArgs: ["integrationId"], }); }); diff --git a/test/unit/commands/integrations/get.test.ts b/test/unit/commands/integrations/get.test.ts index 329e70664..9ca31401e 100644 --- a/test/unit/commands/integrations/get.test.ts +++ b/test/unit/commands/integrations/get.test.ts @@ -213,7 +213,7 @@ describe("integrations:get command", () => { }); describe("error handling", () => { - it("should require ruleId argument", async () => { + it("should require integrationId argument", async () => { const { error } = await runCommand(["integrations:get"], import.meta.url); expect(error).toBeDefined(); @@ -313,6 +313,6 @@ describe("integrations:get command", () => { standardHelpTests("integrations:get", import.meta.url); standardArgValidationTests("integrations:get", import.meta.url, { - requiredArgs: ["ruleId"], + requiredArgs: ["integrationId"], }); }); diff --git a/test/unit/commands/integrations/update.test.ts b/test/unit/commands/integrations/update.test.ts index cf1c36480..8229295a1 100644 --- a/test/unit/commands/integrations/update.test.ts +++ b/test/unit/commands/integrations/update.test.ts @@ -264,7 +264,7 @@ describe("integrations:update command", () => { }, }); - it("should require ruleId argument", async () => { + it("should require integrationId argument", async () => { const { error } = await runCommand( ["integrations:update", "--channel-filter", "test:*"], import.meta.url, @@ -410,6 +410,6 @@ describe("integrations:update command", () => { standardHelpTests("integrations:update", import.meta.url); standardArgValidationTests("integrations:update", import.meta.url, { - requiredArgs: ["ruleId"], + requiredArgs: ["integrationId"], }); });