-
Notifications
You must be signed in to change notification settings - Fork 0
[DX-974] Fix commands params validation, --help documentation and json logging #181
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
54d6ac8
982825f
cab6161
fea0de7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -865,7 +865,7 @@ FLAGS | |
| --json Output in JSON format | ||
| --pretty-json Output in colorized JSON format | ||
| --token-only Output only the token string without any formatting or additional information | ||
| --ttl=<value> [default: 3600] Time to live in seconds (default: 3600, 1 hour) | ||
| --ttl=<value> [default: 3600] Time to live in seconds | ||
|
|
||
| DESCRIPTION | ||
| Create an Ably Token with capabilities | ||
|
|
@@ -910,7 +910,7 @@ FLAGS | |
| --json Output in JSON format | ||
| --pretty-json Output in colorized JSON format | ||
| --token-only Output only the token string without any formatting or additional information | ||
| --ttl=<value> [default: 3600] Time to live in seconds (default: 3600, 1 hour) | ||
| --ttl=<value> [default: 3600] Time to live in seconds | ||
|
|
||
| DESCRIPTION | ||
| Create an Ably JWT token with capabilities | ||
|
|
@@ -1401,11 +1401,15 @@ DESCRIPTION | |
| Manage annotations on Ably Pub/Sub channel messages | ||
|
|
||
| EXAMPLES | ||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:flag.v1" --name thumbsup | ||
| $ ably channels annotations publish my-channel "01234567890:0" "metrics:total.v1" | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:unique.v1" --name thumbsup | ||
|
|
||
| $ ably channels annotations subscribe my-channel | ||
|
|
||
| $ ably channels annotations get my-channel "01234567890:0" | ||
|
|
||
| $ ably channels annotations delete my-channel "01234567890:0" "receipts:flag.v1" | ||
| ``` | ||
|
|
||
| _See code: [src/commands/channels/annotations/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/annotations/index.ts)_ | ||
|
|
@@ -1436,13 +1440,15 @@ DESCRIPTION | |
| Delete an annotation from a channel message | ||
|
|
||
| EXAMPLES | ||
| $ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --name thumbsup | ||
| $ ably channels annotations delete my-channel "01234567890:0" "receipts:flag.v1" | ||
|
|
||
| $ ably channels annotations delete my-channel "01234567890:0" "reactions:multiple.v1" --name thumbsup | ||
| $ ably channels annotations delete my-channel "01234567890:0" "categories:distinct.v1" --name important | ||
|
|
||
| $ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --json | ||
| $ ably channels annotations delete my-channel "01234567890:0" "reactions:unique.v1" --name thumbsup | ||
|
|
||
| $ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --pretty-json | ||
| $ ably channels annotations delete my-channel "01234567890:0" "rating:multiple.v1" --name stars | ||
|
|
||
| $ ably channels annotations delete my-channel "01234567890:0" "receipts:flag.v1" --json | ||
| ``` | ||
|
|
||
| _See code: [src/commands/channels/annotations/delete.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/annotations/delete.ts)_ | ||
|
|
@@ -1509,15 +1515,17 @@ DESCRIPTION | |
| Publish an annotation on a channel message | ||
|
|
||
| EXAMPLES | ||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:flag.v1" --name thumbsup | ||
| $ ably channels annotations publish my-channel "01234567890:0" "metrics:total.v1" | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "receipts:flag.v1" | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:multiple.v1" --name thumbsup --count 3 | ||
| $ ably channels annotations publish my-channel "01234567890:0" "categories:distinct.v1" --name important | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:flag.v1" --data '{"key":"value"}' | ||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:unique.v1" --name thumbsup | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:flag.v1" --json | ||
| $ ably channels annotations publish my-channel "01234567890:0" "rating:multiple.v1" --name stars --count 4 | ||
|
|
||
| $ ably channels annotations publish my-channel "01234567890:0" "reactions:flag.v1" --pretty-json | ||
| $ ably channels annotations publish my-channel "01234567890:0" "metrics:total.v1" --json | ||
| ``` | ||
|
|
||
| _See code: [src/commands/channels/annotations/publish.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/annotations/publish.ts)_ | ||
|
|
@@ -1552,11 +1560,11 @@ EXAMPLES | |
|
|
||
| $ ably channels annotations subscribe my-channel --type "reactions:flag.v1" | ||
|
|
||
| $ ably channels annotations subscribe my-channel --json | ||
|
|
||
| $ ably channels annotations subscribe my-channel --pretty-json | ||
| $ ably channels annotations subscribe my-channel --type "metrics:total.v1" | ||
|
|
||
| $ ably channels annotations subscribe my-channel --duration 30 | ||
|
|
||
| $ ably channels annotations subscribe my-channel --json | ||
| ``` | ||
|
|
||
| _See code: [src/commands/channels/annotations/subscribe.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/annotations/subscribe.ts)_ | ||
|
|
@@ -1698,8 +1706,8 @@ ARGUMENTS | |
|
|
||
| FLAGS | ||
| -v, --verbose Output verbose logs | ||
| --cipher=<value> Decryption key for encrypted messages (AES-128) | ||
| --direction=<option> [default: backwards] Direction of message retrieval (default: backwards) | ||
| --cipher=<value> Decryption key for encrypted messages, uses AES-256 by default | ||
| --direction=<option> [default: backwards] Direction of message retrieval | ||
| <options: backwards|forwards> | ||
| --end=<value> End time as ISO 8601, Unix ms, or relative (e.g., "1h", "30m", "2d") | ||
| --json Output in JSON format | ||
|
|
@@ -1723,7 +1731,7 @@ EXAMPLES | |
|
|
||
| $ ably channels history my-channel --limit 100 | ||
|
|
||
| $ ably channels history my-channel --direction forward | ||
| $ ably channels history my-channel --direction forwards | ||
| ``` | ||
|
|
||
| _See code: [src/commands/channels/history.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/history.ts)_ | ||
|
|
@@ -2021,8 +2029,8 @@ ARGUMENTS | |
| MESSAGE The message to publish (JSON format or plain text) | ||
|
|
||
| FLAGS | ||
| -c, --count=<value> [default: 1] Number of messages to publish (default: 1) | ||
| -d, --delay=<value> [default: 40] Delay between messages in milliseconds (default: 40ms, max 25 msgs/sec) | ||
| -c, --count=<value> [default: 1] Number of messages to publish | ||
| -d, --delay=<value> [default: 40] Delay between messages in milliseconds (max 25 msgs/sec) | ||
| -e, --encoding=<value> The encoding for the message | ||
| -n, --name=<value> The event name (if not specified in the message JSON) | ||
| -v, --verbose Output verbose logs | ||
|
|
@@ -2078,13 +2086,13 @@ ARGUMENTS | |
| FLAGS | ||
| -D, --duration=<value> Automatically exit after N seconds | ||
| -v, --verbose Output verbose logs | ||
| --cipher-algorithm=<value> [default: aes] Encryption algorithm to use (default: aes) | ||
| --cipher-key=<value> Encryption key for decrypting messages (hex-encoded) | ||
| --cipher-key-length=<value> [default: 256] Length of encryption key in bits (default: 256) | ||
| --cipher-mode=<value> [default: cbc] Cipher mode to use (default: cbc) | ||
| --cipher-algorithm=<value> [default: aes] Encryption algorithm to use | ||
| --cipher-key=<value> Encryption key for decrypting messages (base64-encoded or hex-encoded) | ||
| --cipher-key-length=<value> [default: 256] Length of encryption key in bits | ||
| --cipher-mode=<value> [default: cbc] Cipher mode to use | ||
| --client-id=<value> Overrides any default client ID when using API authentication. Use "none" to | ||
| explicitly set no client ID. Not applicable when using token authentication. | ||
| --delta Enable delta compression for messages | ||
| --delta Enable delta compression (VCDIFF) to reduce message payload sizes | ||
| --json Output in JSON format | ||
| --pretty-json Output in colorized JSON format | ||
| --rewind=<value> Number of messages to rewind when subscribing (default: 0) | ||
|
|
@@ -2358,13 +2366,13 @@ FLAGS | |
| --channel-filter=<value> Channel filter pattern | ||
| --json Output in JSON format | ||
| --pretty-json Output in colorized JSON format | ||
| --request-mode=<option> [default: single] Request mode for the integration (default: single) | ||
| --request-mode=<option> [default: single] Request mode for the integration | ||
| <options: single|batch> | ||
| --rule-type=<option> (required) Type of integration (http, amqp, etc.) | ||
| <options: http|amqp|kinesis|firehose|pulsar|kafka|azure|azure-functions|mqtt|cloudmqtt> | ||
| --source-type=<option> (required) The event source type | ||
| <options: channel.message|channel.presence|channel.lifecycle|presence.message> | ||
| --status=<option> [default: enabled] Initial status of the integration (default: enabled) | ||
| --status=<option> [default: enabled] Initial status of the integration | ||
| <options: enabled|disabled> | ||
| --target-url=<value> Target URL for HTTP integrations | ||
|
|
||
|
|
@@ -3554,19 +3562,19 @@ FLAGS | |
| -v, --verbose Output verbose logs | ||
| --app=<value> The app ID or name (defaults to current app) | ||
| --json Output in JSON format | ||
| --max-length=<value> [default: 10000] Maximum number of messages in the queue (default: 10000) | ||
| --max-length=<value> [default: 10000] Maximum number of messages in the queue (max: 10000) | ||
| --name=<value> (required) Name of the queue | ||
| --pretty-json Output in colorized JSON format | ||
| --region=<value> [default: us-east-1-a] Region for the queue (default: us-east-1-a) | ||
| --ttl=<value> [default: 60] Time to live for messages in seconds (default: 60) | ||
| --region=<value> [default: us-east-1-a] Region for the queue (e.g., us-east-1-a, eu-west-1-a) | ||
| --ttl=<value> [default: 60] Time to live for messages in seconds (max: 3600) | ||
|
|
||
| DESCRIPTION | ||
| Create a queue | ||
|
|
||
| EXAMPLES | ||
| $ ably queues create --name "my-queue" | ||
|
|
||
| $ ably queues create --name "my-queue" --ttl 3600 --max-length 100000 | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are showing |
||
| $ ably queues create --name "my-queue" --ttl 300 --max-length 5000 | ||
|
|
||
| $ ably queues create --name "my-queue" --region "eu-west-1-a" --app "My App" | ||
|
|
||
|
|
@@ -3772,7 +3780,7 @@ FLAGS | |
| -v, --verbose Output verbose logs | ||
| --end=<value> End time as ISO 8601, Unix ms, or relative (e.g., "1h", "30m", "2d") | ||
| --json Output in JSON format | ||
| --order=<option> [default: newestFirst] Query direction: oldestFirst or newestFirst (default: newestFirst) | ||
| --order=<option> [default: newestFirst] Order of results: oldestFirst or newestFirst | ||
| <options: oldestFirst|newestFirst> | ||
| --pretty-json Output in colorized JSON format | ||
| --show-metadata Display message metadata if available | ||
|
|
@@ -3953,8 +3961,8 @@ ARGUMENTS | |
| TEXT The message text to send | ||
|
|
||
| FLAGS | ||
| -c, --count=<value> [default: 1] Number of messages to send (default: 1) | ||
| -d, --delay=<value> [default: 40] Delay between messages in milliseconds (default: 40ms, max 25 msgs/sec) | ||
| -c, --count=<value> [default: 1] Number of messages to send | ||
| -d, --delay=<value> [default: 40] Delay between messages in milliseconds (max 25 msgs/sec) | ||
| -v, --verbose Output verbose logs | ||
| --client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set | ||
| no client ID. Not applicable when using token authentication. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -32,6 +32,9 @@ export default class AppsCreateCommand extends ControlBaseCommand { | |
|
|
||
| async run(): Promise<void> { | ||
| const { flags } = await this.parse(AppsCreateCommand); | ||
| if (!flags.name?.trim()) { | ||
| this.fail("App name cannot be empty", flags, "parse"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment... i don't think we need empty string validation... there are a few instances of this in the PR, can you check them all please
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, forgot to mention, intentionally kept for rules, queues and keys
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Only for
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if you want, I can remove it, but check is not repetitive as such
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should have 1 way of doing things, we either add this empty string validation to all flags or none. I don't think it adds any value tbh... required flags are already validated by oclif, and the "system" would throw an error if necessary if someone passed an empty string
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Problem is |
||
| } | ||
|
|
||
| try { | ||
| const controlApi = this.createControlApi(flags); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,9 @@ export default class RulesCreateCommand extends ControlBaseCommand { | |
|
|
||
| async run(): Promise<void> { | ||
| const { flags } = await this.parse(RulesCreateCommand); | ||
| if (!flags.name?.trim()) { | ||
| this.fail("Rule name cannot be empty", flags, "parse"); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as previous comment... i don't think we need empty string validation |
||
| } | ||
|
|
||
| const appId = await this.requireAppId(flags); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,10 +33,11 @@ export default class ChannelsAnnotationsDelete extends AblyBaseCommand { | |
| static override description = "Delete an annotation from a channel message"; | ||
|
|
||
| static override examples = [ | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --name thumbsup', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "reactions:multiple.v1" --name thumbsup', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --json', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "reactions:flag.v1" --pretty-json', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "receipts:flag.v1"', | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| '$ ably channels annotations delete my-channel "01234567890:0" "categories:distinct.v1" --name important', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "reactions:unique.v1" --name thumbsup', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "rating:multiple.v1" --name stars', | ||
| '$ ably channels annotations delete my-channel "01234567890:0" "receipts:flag.v1" --json', | ||
| ]; | ||
|
|
||
| static override flags = { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to show
defaulttwice in help methods