Skip to content

Commit b048ad7

Browse files
committed
- Removed unnecessary static cipher-algorithm, cipher-key-length and cipher-mode flags
- Avoided opening url in browser in json mode
1 parent 998d8b6 commit b048ad7

6 files changed

Lines changed: 33 additions & 64 deletions

File tree

README.md

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ $ npm install -g @ably/cli
2424
$ ably COMMAND
2525
running command...
2626
$ ably (--version)
27-
@ably/cli/0.17.0 darwin-arm64 node-v24.4.1
27+
@ably/cli/0.17.0 darwin-arm64 node-v25.3.0
2828
$ ably --help [COMMAND]
2929
USAGE
3030
$ ably COMMAND
@@ -1949,7 +1949,7 @@ _See code: [src/commands/channels/presence/enter.ts](https://github.com/ably/abl
19491949

19501950
Get all current presence members on a channel
19511951

1952-
```text
1952+
```
19531953
USAGE
19541954
$ ably channels presence get CHANNEL [-v] [--json | --pretty-json] [--limit <value>]
19551955
@@ -2077,26 +2077,23 @@ Subscribe to messages published on one or more Ably channels
20772077
```
20782078
USAGE
20792079
$ ably channels subscribe CHANNELS... [-v] [--json | --pretty-json] [--client-id <value>] [-D <value>] [--rewind
2080-
<value>] [--cipher-algorithm <value>] [--cipher-key <value>] [--cipher-key-length <value>] [--cipher-mode <value>]
2081-
[--delta] [--sequence-numbers]
2080+
<value>] [--cipher <value>] [--delta] [--sequence-numbers]
20822081
20832082
ARGUMENTS
20842083
CHANNELS... Channel name(s) to subscribe to
20852084
20862085
FLAGS
2087-
-D, --duration=<value> Automatically exit after N seconds
2088-
-v, --verbose Output verbose logs
2089-
--cipher-algorithm=<value> [default: aes] Encryption algorithm to use
2090-
--cipher-key=<value> Encryption key for decrypting messages (base64-encoded or hex-encoded)
2091-
--cipher-key-length=<value> [default: 256] Length of encryption key in bits
2092-
--cipher-mode=<value> [default: cbc] Cipher mode to use
2093-
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to
2094-
explicitly set no client ID. Not applicable when using token authentication.
2095-
--delta Enable delta compression (VCDIFF) to reduce message payload sizes
2096-
--json Output in JSON format
2097-
--pretty-json Output in colorized JSON format
2098-
--rewind=<value> Number of messages to rewind when subscribing (default: 0)
2099-
--sequence-numbers Include sequence numbers in output
2086+
-D, --duration=<value> Automatically exit after N seconds
2087+
-v, --verbose Output verbose logs
2088+
--cipher=<value> Decryption key for encrypted messages (base64-encoded or hex-encoded), uses AES-256-CBC by
2089+
default
2090+
--client-id=<value> Overrides any default client ID when using API authentication. Use "none" to explicitly set
2091+
no client ID. Not applicable when using token authentication.
2092+
--delta Enable delta compression (VCDIFF) to reduce message payload sizes
2093+
--json Output in JSON format
2094+
--pretty-json Output in colorized JSON format
2095+
--rewind=<value> Number of messages to rewind when subscribing (default: 0)
2096+
--sequence-numbers Include sequence numbers in output
21002097
21012098
DESCRIPTION
21022099
Subscribe to messages published on one or more Ably channels
@@ -2110,7 +2107,7 @@ EXAMPLES
21102107
21112108
$ ably channels subscribe --delta my-channel
21122109
2113-
$ ably channels subscribe --cipher-key YOUR_CIPHER_KEY my-channel
2110+
$ ably channels subscribe --cipher YOUR_CIPHER_KEY my-channel
21142111
21152112
$ ably channels subscribe my-channel --json
21162113

src/commands/channels/inspect.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,10 @@ export default class ChannelsInspect extends AblyBaseCommand {
5454
}
5555
const url = `${dashboardHost}/accounts/${accountId}/apps/${appId}/channels/${encodeURIComponent(args.channel)}`;
5656

57-
const isJson = this.shouldOutputJson(flags);
58-
if (isJson) {
59-
this.logJsonResult({ message: `Opening ${url} in your browser` }, flags);
57+
if (this.shouldOutputJson(flags)) {
58+
this.logJsonResult({ message: `Open ${url} in your browser` }, flags);
59+
} else {
60+
await openUrl(url, this);
6061
}
61-
62-
await openUrl(url, this, isJson);
6362
}
6463
}

src/commands/channels/subscribe.ts

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default class ChannelsSubscribe extends AblyBaseCommand {
3535
"$ ably channels subscribe my-channel another-channel",
3636
"$ ably channels subscribe --rewind 10 my-channel",
3737
"$ ably channels subscribe --delta my-channel",
38-
"$ ably channels subscribe --cipher-key YOUR_CIPHER_KEY my-channel",
38+
"$ ably channels subscribe --cipher YOUR_CIPHER_KEY my-channel",
3939
"$ ably channels subscribe my-channel --json",
4040
"$ ably channels subscribe my-channel --pretty-json",
4141
"$ ably channels subscribe my-channel --duration 30",
@@ -47,21 +47,9 @@ export default class ChannelsSubscribe extends AblyBaseCommand {
4747
...clientIdFlag,
4848
...durationFlag,
4949
...rewindFlag,
50-
"cipher-algorithm": Flags.string({
51-
default: "aes",
52-
description: "Encryption algorithm to use",
53-
}),
54-
"cipher-key": Flags.string({
50+
cipher: Flags.string({
5551
description:
56-
"Encryption key for decrypting messages (base64-encoded or hex-encoded)",
57-
}),
58-
"cipher-key-length": Flags.integer({
59-
default: 256,
60-
description: "Length of encryption key in bits",
61-
}),
62-
"cipher-mode": Flags.string({
63-
default: "cbc",
64-
description: "Cipher mode to use",
52+
"Decryption key for encrypted messages (base64-encoded or hex-encoded), uses AES-256-CBC by default",
6553
}),
6654
delta: Flags.boolean({
6755
default: false,
@@ -107,19 +95,16 @@ export default class ChannelsSubscribe extends AblyBaseCommand {
10795
const channelOptions: Ably.ChannelOptions = {};
10896

10997
// Configure encryption if cipher key is provided
110-
if (flags["cipher-key"]) {
98+
if (flags.cipher) {
11199
channelOptions.cipher = {
112-
algorithm: flags["cipher-algorithm"],
113-
key: flags["cipher-key"],
114-
keyLength: flags["cipher-key-length"],
115-
mode: flags["cipher-mode"],
100+
key: flags.cipher,
116101
};
117102
this.logCliEvent(
118103
flags,
119104
"subscribe",
120105
"encryptionEnabled",
121106
`Encryption enabled for channel ${channelName}`,
122-
{ algorithm: flags["cipher-algorithm"], channel: channelName },
107+
{ channel: channelName },
123108
);
124109
}
125110

src/commands/status.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export default class StatusCommand extends AblyBaseCommand {
8787
}
8888

8989
if (flags.open) {
90-
await openUrl("https://status.ably.com", this, isJson);
90+
await openUrl("https://status.ably.com", this);
9191
}
9292
} catch (error) {
9393
if (spinner) {

src/utils/open-url.ts

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,16 @@ interface Logger {
1111
// In web CLI mode it prints "Visit <url>" instead of trying to open a browser.
1212
// We don't want to open browsers in unit tests, and we can't use mocking to catch the calls because of how
1313
// oclif loads the commands.
14-
// When isJsonOutput is true, human-readable messages are suppressed — callers are responsible for emitting
15-
// proper JSON envelope output via logJsonResult/logJsonEvent before calling openUrl.
16-
const openUrl = async (
17-
url: string,
18-
logger: Logger,
19-
isJsonOutput = false,
20-
): Promise<void> => {
14+
const openUrl = async (url: string, logger: Logger): Promise<void> => {
2115
if (isWebCliMode()) {
22-
if (!isJsonOutput) {
23-
logger.log(`${chalk.cyan("Visit")} ${url}`);
24-
}
16+
logger.log(`${chalk.cyan("Visit")} ${url}`);
2517
return;
2618
}
27-
if (!isJsonOutput) {
28-
logger.log(
29-
`${chalk.cyan("Opening")} ${url} ${chalk.cyan("in your browser")}...`,
30-
);
31-
}
19+
logger.log(
20+
`${chalk.cyan("Opening")} ${url} ${chalk.cyan("in your browser")}...`,
21+
);
3222
if (isTestMode()) {
33-
if (!isJsonOutput) {
34-
logger.log(`would open URL in browser: ${url}`);
35-
}
23+
logger.log(`would open URL in browser: ${url}`);
3624
return;
3725
}
3826
await open(url);

test/unit/commands/channels/subscribe.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ describe("channels:subscribe command", () => {
5050
standardFlagTests("channels:subscribe", import.meta.url, [
5151
"--rewind",
5252
"--delta",
53-
"--cipher-key",
53+
"--cipher",
5454
"--json",
5555
]);
5656

0 commit comments

Comments
 (0)