Skip to content

Standardize command arguments#354

Merged
sacOO7 merged 3 commits intomainfrom
fix/standardize-argument-names-output-to-snake-case
Apr 20, 2026
Merged

Standardize command arguments#354
sacOO7 merged 3 commits intomainfrom
fix/standardize-argument-names-output-to-snake-case

Conversation

@sacOO7
Copy link
Copy Markdown
Contributor

@sacOO7 sacOO7 commented Apr 17, 2026

  • Standardized positional argument names to POSIX-compliant snake_case display.
  • Adds a camelToSnake transform in the custom help class to convert camelCase arg names to snake_case before oclif uppercases them. This also helps codebase to maintain camelCase argument naming across commands while keeping them verbose.
  • Made argument names more verbose and readable making sure consistency is well preserved across commands. Same is reflected in --help output display.

Arguments

Before After Help Output
alias accountAlias ACCOUNT_ALIAS instead of ACCOUNTALIAS
channel channelName CHANNEL_NAME
channels channelNames CHANNEL_NAMES
"device-id" deviceId DEVICE_ID
id appId APP_ID
ruleId integrationId INTEGRATION_ID
room roomName ROOM_NAME
rooms roomNames ROOM_NAMES
serial messageSerial MESSAGE_SERIAL
space_name spaceName SPACE_NAME
type annotationType ANNOTATION_TYPE

Summary

  • Normalize all positional argument keys to camelCase across 59 command files, replacing three inconsistent conventions (camelCase-derived like ruleId, underscore like space_name, and hyphenated like device-id) with a single camelCase convention in source code.
  • Add camelToSnake transform in src/help.ts that temporarily converts camelCase arg names to snake_case before oclif's formatCommand() uppercases them, producing readable UPPER_SNAKE_CASE placeholders in help output (e.g., spaceNameSPACE_NAME, messageSerialMESSAGE_SERIAL).
  • Make argument names self-documenting — ambiguous names like id, serial, and channel are now appId, messageSerial, and channelName, making help output clearer without needing to read descriptions.
  • Update corresponding test file for spaces commands.

- 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`
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cli-web-cli Ready Ready Preview, Comment Apr 20, 2026 4:40pm

Request Review

@sacOO7 sacOO7 changed the title Standardize positional argument names to POSIX-compliant snake_case display Standardized all command arguments Apr 17, 2026
@sacOO7 sacOO7 changed the title Standardized all command arguments Standardize all command arguments Apr 17, 2026
@sacOO7 sacOO7 changed the title Standardize all command arguments Standardize command arguments Apr 17, 2026
- Added separate hook to apply camelCase to snake_case transformation
- Simplified generate-doc to re-use `doc-template.md`
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR standardizes positional argument identifiers across the CLI command sources to consistent camelCase, while ensuring the rendered help/readme placeholders remain readable as UPPER_SNAKE_CASE (via a camel→snake transform before oclif uppercases them).

Changes:

  • Renames positional args across commands to consistent, more descriptive camelCase keys (e.g., space_namespaceName, roomroomName, serialmessageSerial).
  • Updates CustomHelp (and a new init hook for doc generation) to render arg placeholders as UPPER_SNAKE_CASE in help/readme output.
  • Adjusts doc generation scaffolding and updates the affected Spaces unit test assertion.

Reviewed changes

Copilot reviewed 64 out of 64 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/unit/commands/spaces/spaces.test.ts Updates help-output expectation (LOCK_ID).
src/hooks/init/patch-arg-names.ts Adds init hook to patch arg names during GENERATING_DOC=true readme generation.
src/help.ts Adds camelToSnake + temporary arg-name patching during formatCommand() to improve help placeholders.
src/commands/stats/app.ts Renames id arg to appId and updates usage.
src/commands/spaces/subscribe.ts Renames space_name to spaceName.
src/commands/spaces/occupancy/subscribe.ts Renames space_name to spaceName + updates error context.
src/commands/spaces/occupancy/get.ts Renames space_name to spaceName + updates error context.
src/commands/spaces/members/subscribe.ts Renames space_name to spaceName.
src/commands/spaces/members/get.ts Renames space_name to spaceName.
src/commands/spaces/members/enter.ts Renames space_name to spaceName.
src/commands/spaces/locks/subscribe.ts Renames space_name to spaceName.
src/commands/spaces/locks/get.ts Renames space_name to spaceName.
src/commands/spaces/locks/acquire.ts Renames space_name to spaceName.
src/commands/spaces/locations/subscribe.ts Renames space_name to spaceName.
src/commands/spaces/locations/set.ts Renames space_name to spaceName.
src/commands/spaces/locations/get.ts Renames space_name to spaceName.
src/commands/spaces/get.ts Renames space_name to spaceName.
src/commands/spaces/cursors/subscribe.ts Renames space_name to spaceName.
src/commands/spaces/cursors/set.ts Renames space_name to spaceName.
src/commands/spaces/cursors/get.ts Renames space_name to spaceName.
src/commands/spaces/create.ts Renames space_name to spaceName.
src/commands/rooms/typing/subscribe.ts Renames room to roomName + updates error context.
src/commands/rooms/typing/keystroke.ts Renames room to roomName + updates error context.
src/commands/rooms/reactions/subscribe.ts Renames room to roomName + updates error context.
src/commands/rooms/reactions/send.ts Renames room to roomName.
src/commands/rooms/presence/subscribe.ts Renames room to roomName.
src/commands/rooms/presence/get.ts Renames room to roomName + updates error context.
src/commands/rooms/presence/enter.ts Renames room to roomName.
src/commands/rooms/occupancy/subscribe.ts Renames room to roomName.
src/commands/rooms/occupancy/get.ts Renames room to roomName + updates error context.
src/commands/rooms/messages/update.ts Renames roomroomName, serialmessageSerial throughout.
src/commands/rooms/messages/subscribe.ts Renames rooms to roomNames for help/args key consistency.
src/commands/rooms/messages/send.ts Renames room to roomName throughout.
src/commands/rooms/messages/reactions/subscribe.ts Renames room to roomName + updates error context.
src/commands/rooms/messages/reactions/send.ts Renames room to roomName (local alias retained as room).
src/commands/rooms/messages/reactions/remove.ts Renames room to roomName (local alias retained as room).
src/commands/rooms/messages/history.ts Renames room to roomName + updates error context.
src/commands/rooms/messages/delete.ts Renames roomroomName, serialmessageSerial throughout.
src/commands/push/devices/remove.ts Renames "device-id" arg key to deviceId and updates access.
src/commands/push/devices/get.ts Renames "device-id" arg key to deviceId and updates access.
src/commands/integrations/delete.ts Renames integrationId to ruleId and updates API calls.
src/commands/channels/update.ts Renames channelchannelName, serialmessageSerial throughout.
src/commands/channels/subscribe.ts Renames channels to channelNames for help/args key consistency.
src/commands/channels/publish.ts Renames channel to channelName throughout.
src/commands/channels/presence/subscribe.ts Renames channel to channelName + updates error context.
src/commands/channels/presence/get.ts Renames channel to channelName + updates error context.
src/commands/channels/presence/enter.ts Renames channel to channelName + updates error context.
src/commands/channels/occupancy/subscribe.ts Renames channel to channelName + updates error context.
src/commands/channels/occupancy/get.ts Renames channel to channelName + updates error context.
src/commands/channels/inspect.ts Renames channel to channelName (URL generation).
src/commands/channels/history.ts Renames channel to channelName.
src/commands/channels/delete.ts Renames channelchannelName, serialmessageSerial.
src/commands/channels/append.ts Renames channelchannelName, serialmessageSerial.
src/commands/channels/annotations/subscribe.ts Renames channel to channelName.
src/commands/channels/annotations/publish.ts Renames channelchannelName, serialmessageSerial, typeannotationType.
src/commands/channels/annotations/get.ts Renames channelchannelName, serialmessageSerial.
src/commands/channels/annotations/delete.ts Renames channelchannelName, serialmessageSerial, typeannotationType.
src/commands/bench/subscriber.ts Renames channel to channelName throughout.
src/commands/bench/publisher.ts Renames channel to channelName throughout (including typed args).
src/commands/apps/update.ts Renames id to appId throughout.
src/commands/accounts/switch.ts Renames alias to accountAlias throughout.
src/commands/accounts/logout.ts Renames alias to accountAlias throughout.
scripts/doc-template.md Adds a reusable readme template skeleton for doc generation.
package.json Updates generate-doc to use the template and registers the new init hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +16 to +19
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();
}
Copy link

Copilot AI Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The camelCase→snake_case transform here duplicates the camelToSnake() logic added in src/help.ts. To avoid divergence (e.g., if the regex ever needs to change to handle acronyms/edge cases), consider extracting a small shared helper (e.g., in src/utils/) and using it in both the init hook and CustomHelp.formatCommand().

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@claude-code-ably-assistant
Copy link
Copy Markdown

Walkthrough

This PR standardizes positional argument names across all CLI commands, making them more descriptive (channelchannelName, roomroomName, etc.) and ensuring they display as UPPER_SNAKE_CASE in help output. It introduces a camelToSnake() transform in the help class that temporarily patches arg names during formatCommand(), so internal code stays camelCase while help text renders cleanly. A new patch-arg-names init hook handles the same transformation for the doc-generation code path.

Changes

Area Files Summary
Commands – Channels channels/publish, subscribe, history, inspect, occupancy/*, presence/*, annotations/*, append, delete, update Renamed channelchannelName, channelschannelNames, serialmessageSerial, typeannotationType
Commands – Rooms rooms/messages/*, rooms/occupancy/*, rooms/presence/*, rooms/reactions/*, rooms/typing/* Renamed roomroomName, roomsroomNames, serialmessageSerial
Commands – Spaces spaces/*, spaces/cursors/*, spaces/locations/*, spaces/locks/*, spaces/members/*, spaces/occupancy/* Renamed space_namespaceName (also fixes prior underscore inconsistency)
Commands – Accounts/Apps/Stats accounts/logout, accounts/switch, apps/update, stats/app Renamed aliasaccountAlias, idappId
Commands – Push/Integrations/Bench push/devices/get, push/devices/remove, integrations/delete, bench/publisher, bench/subscriber Renamed device-iddeviceId, integrationIdruleId, channelchannelName
Help src/help.ts Added camelToSnake() helper; patches/restores arg names around formatCommand() so oclif uppercases them as UPPER_SNAKE_CASE
Hooks src/hooks/init/patch-arg-names.ts (new) Init hook that applies snake_case patching when GENERATING_DOC=true, covering the readme generator's code path
Config package.json Registers new patch-arg-names init hook; simplifies generate-doc script to use a template file
Docs / Scripts scripts/doc-template.md (new) Extracts the boilerplate TOC/commands template previously inlined in generate-doc
Tests test/unit/commands/spaces/spaces.test.ts Updated assertion from LOCKIDLOCK_ID to match the new camelToSnake output

Review Notes

  • Breaking change for scripting users: Positional argument keys are internal to oclif's arg parsing, but any test or script that references arg names by key (e.g. args.channel) will break — reviewers should confirm all call sites referencing old names have been updated.
  • Patch-and-restore pattern in help.ts: The camelToSnake approach mutates command.args temporarily and restores it — reviewers should check for thread-safety / reentrancy if help formatting is ever called concurrently.
  • New init hook scope: patch-arg-names only activates when GENERATING_DOC=true; confirm this env var is set in the generate-doc script and that it has no unintended side effects in other workflows.
  • Test coverage gap: Only one test file was updated. Given 59 command files changed, consider whether integration/E2E tests cover the renamed args end-to-end, especially for multi-arg commands like annotations/delete (channelName, messageSerial, annotationType).
  • integrationIdruleId rename: This is a semantic rename (not just formatting). Confirm no external docs, scripts, or API references use the old key name.

@sacOO7 sacOO7 requested a review from AndyTWF April 17, 2026 11:29
Copy link
Copy Markdown

@claude-code-ably-assistant claude-code-ably-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

File Status Notes
src/help.ts OK try/finally restore is correct
src/hooks/init/patch-arg-names.ts Minor Duplicates camelToSnake logic
src/commands/**/*.ts (59 files) OK Mechanical renames, all correct
test/unit/commands/spaces/spaces.test.ts OK LOCKIDLOCK_ID updated correctly

One thing worth fixing

camelToSnake logic is duplicated across two files

The regex /([a-z])([A-Z])/g with .toLowerCase() appears as a named function in src/help.ts (line 13–15) and then repeated inline in src/hooks/init/patch-arg-names.ts (line 19). If the transform ever needs to change (e.g., to handle acronyms like appID), one place gets updated and the other doesn't — causing the --help body and the generated readme to silently diverge.

The hook could import camelToSnake from help.ts, or both could import from a small shared utility. Either way, one source of truth.

Everything else looks good

  • The try/finally pattern in formatCommand() correctly restores arg names after oclif mutates them — no risk of the patched names leaking into subsequent calls.
  • The hook guards on GENERATING_DOC !== "true" so it is a no-op in normal CLI usage — zero runtime cost per invocation.
  • Test coverage is sufficient: the bench test's toContain("CHANNEL") still matches the new CHANNEL_NAME output (substring match), and the spaces test was correctly updated to LOCK_ID.
  • No this.error() calls, no JSON output contract issues, no flag architecture problems.

@sacOO7 sacOO7 requested a review from umair-ably April 17, 2026 11:31
Comment thread src/commands/integrations/delete.ts Outdated
export default class IntegrationsDeleteCommand extends ControlBaseCommand {
static args = {
integrationId: Args.string({
ruleId: Args.string({
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In our documentation, rules refers to the conditions set on channel namespaces (forced client IDs etc). Integrations are things like Lambda, Kafka - which is what this command is doing.

I think the flag should therefore be integrationId everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, will update accordingly 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/hooks/init/patch-arg-names.ts Outdated

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this should be something shared somewhere seeing as we have it in help.ts too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, will update accordingly 👍

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sacOO7 sacOO7 force-pushed the fix/standardize-argument-names-output-to-snake-case branch from e53b975 to 895f41c Compare April 20, 2026 16:39
@sacOO7 sacOO7 merged commit fa80363 into main Apr 20, 2026
11 checks passed
@sacOO7 sacOO7 deleted the fix/standardize-argument-names-output-to-snake-case branch April 20, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants