Skip to content

Commit 01dd970

Browse files
committed
Renamed channels presence get-all to get, marked clientId as required in
channels presence update
1 parent 3f6a2f1 commit 01dd970

5 files changed

Lines changed: 47 additions & 30 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ $ ably-interactive
121121
* [`ably channels occupancy subscribe CHANNEL`](#ably-channels-occupancy-subscribe-channel)
122122
* [`ably channels presence`](#ably-channels-presence)
123123
* [`ably channels presence enter CHANNEL`](#ably-channels-presence-enter-channel)
124-
* [`ably channels presence get-all CHANNEL`](#ably-channels-presence-get-all-channel)
124+
* [`ably channels presence get CHANNEL`](#ably-channels-presence-get-channel)
125125
* [`ably channels presence subscribe CHANNEL`](#ably-channels-presence-subscribe-channel)
126126
* [`ably channels presence update CHANNEL`](#ably-channels-presence-update-channel)
127127
* [`ably channels publish CHANNEL MESSAGE`](#ably-channels-publish-channel-message)
@@ -1940,13 +1940,13 @@ EXAMPLES
19401940

19411941
_See code: [src/commands/channels/presence/enter.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/presence/enter.ts)_
19421942

1943-
## `ably channels presence get-all CHANNEL`
1943+
## `ably channels presence get CHANNEL`
19441944

19451945
Get all current presence members on a channel
19461946

19471947
```
19481948
USAGE
1949-
$ ably channels presence get-all CHANNEL [-v] [--json | --pretty-json] [--limit <value>]
1949+
$ ably channels presence get CHANNEL [-v] [--json | --pretty-json] [--limit <value>]
19501950
19511951
ARGUMENTS
19521952
CHANNEL Channel name to get presence members for
@@ -1961,16 +1961,16 @@ DESCRIPTION
19611961
Get all current presence members on a channel
19621962
19631963
EXAMPLES
1964-
$ ably channels presence get-all my-channel
1964+
$ ably channels presence get my-channel
19651965
1966-
$ ably channels presence get-all my-channel --limit 50
1966+
$ ably channels presence get my-channel --limit 50
19671967
1968-
$ ably channels presence get-all my-channel --json
1968+
$ ably channels presence get my-channel --json
19691969
1970-
$ ably channels presence get-all my-channel --pretty-json
1970+
$ ably channels presence get my-channel --pretty-json
19711971
```
19721972

1973-
_See code: [src/commands/channels/presence/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/presence/get-all.ts)_
1973+
_See code: [src/commands/channels/presence/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/channels/presence/get.ts)_
19741974

19751975
## `ably channels presence subscribe CHANNEL`
19761976

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
formatPaginationLog,
2121
} from "../../../utils/pagination.js";
2222

23-
export default class ChannelsPresenceGetAll extends AblyBaseCommand {
23+
export default class ChannelsPresenceGet extends AblyBaseCommand {
2424
static override args = {
2525
channel: Args.string({
2626
description: "Channel name to get presence members for",
@@ -31,10 +31,10 @@ export default class ChannelsPresenceGetAll extends AblyBaseCommand {
3131
static override description = "Get all current presence members on a channel";
3232

3333
static override examples = [
34-
"$ ably channels presence get-all my-channel",
35-
"$ ably channels presence get-all my-channel --limit 50",
36-
"$ ably channels presence get-all my-channel --json",
37-
"$ ably channels presence get-all my-channel --pretty-json",
34+
"$ ably channels presence get my-channel",
35+
"$ ably channels presence get my-channel --limit 50",
36+
"$ ably channels presence get my-channel --json",
37+
"$ ably channels presence get my-channel --pretty-json",
3838
];
3939

4040
static override flags = {
@@ -47,7 +47,7 @@ export default class ChannelsPresenceGetAll extends AblyBaseCommand {
4747
};
4848

4949
async run(): Promise<void> {
50-
const { args, flags } = await this.parse(ChannelsPresenceGetAll);
50+
const { args, flags } = await this.parse(ChannelsPresenceGet);
5151

5252
try {
5353
const client = await this.createAblyRestClient(flags);
@@ -154,7 +154,7 @@ export default class ChannelsPresenceGetAll extends AblyBaseCommand {
154154
}
155155
}
156156
} catch (error) {
157-
this.fail(error, flags, "presenceGetAll", {
157+
this.fail(error, flags, "presenceGet", {
158158
channel: args.channel,
159159
});
160160
}

src/commands/channels/presence/update.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,13 @@ export default class ChannelsPresenceUpdate extends AblyBaseCommand {
3030

3131
static override flags = {
3232
...productApiFlags,
33-
...clientIdFlag,
33+
"client-id": Flags.string({
34+
description:
35+
'Overrides any default client ID when using API authentication. Use "none" to explicitly set no client ID. Not applicable when using token authentication.',
36+
required: true,
37+
}),
3438
data: Flags.string({
3539
description: "JSON data to associate with the presence update",
36-
required: true,
3740
}),
3841
...durationFlag,
3942
};
@@ -51,7 +54,7 @@ export default class ChannelsPresenceUpdate extends AblyBaseCommand {
5154
const client = this.client;
5255
const { channel: channelName } = args;
5356

54-
const data = this.parseJsonFlag(flags.data, "data", flags);
57+
const data = this.parseJsonFlag(flags.data ?? "{}", "data", flags);
5558

5659
this.channel = client.channels.get(channelName);
5760

test/unit/commands/channels/presence/get-all.test.ts renamed to test/unit/commands/channels/presence/get.test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const mockPresenceMembers = [
3131
},
3232
];
3333

34-
describe("channels:presence:get-all command", () => {
34+
describe("channels:presence:get command", () => {
3535
beforeEach(() => {
3636
const mock = getMockAblyRest();
3737
const channel = mock.channels._getChannel("test-channel");
@@ -41,11 +41,11 @@ describe("channels:presence:get-all command", () => {
4141
);
4242
});
4343

44-
standardHelpTests("channels:presence:get-all", import.meta.url);
45-
standardArgValidationTests("channels:presence:get-all", import.meta.url, {
44+
standardHelpTests("channels:presence:get", import.meta.url);
45+
standardArgValidationTests("channels:presence:get", import.meta.url, {
4646
requiredArgs: ["test-channel"],
4747
});
48-
standardFlagTests("channels:presence:get-all", import.meta.url, [
48+
standardFlagTests("channels:presence:get", import.meta.url, [
4949
"--limit",
5050
"--json",
5151
"--pretty-json",
@@ -57,7 +57,7 @@ describe("channels:presence:get-all command", () => {
5757
const channel = mock.channels._getChannel("test-channel");
5858

5959
const { stdout } = await runCommand(
60-
["channels:presence:get-all", "test-channel"],
60+
["channels:presence:get", "test-channel"],
6161
import.meta.url,
6262
);
6363

@@ -75,7 +75,7 @@ describe("channels:presence:get-all command", () => {
7575
channel.presence.get.mockResolvedValue(createMockPaginatedResult([]));
7676

7777
const { stderr } = await runCommand(
78-
["channels:presence:get-all", "test-channel"],
78+
["channels:presence:get", "test-channel"],
7979
import.meta.url,
8080
);
8181

@@ -84,7 +84,7 @@ describe("channels:presence:get-all command", () => {
8484

8585
it("should output JSON with presenceMembers array", async () => {
8686
const { stdout } = await runCommand(
87-
["channels:presence:get-all", "test-channel", "--json"],
87+
["channels:presence:get", "test-channel", "--json"],
8888
import.meta.url,
8989
);
9090

@@ -104,7 +104,7 @@ describe("channels:presence:get-all command", () => {
104104

105105
it("should display member data when present", async () => {
106106
const { stdout } = await runCommand(
107-
["channels:presence:get-all", "test-channel"],
107+
["channels:presence:get", "test-channel"],
108108
import.meta.url,
109109
);
110110

@@ -118,7 +118,7 @@ describe("channels:presence:get-all command", () => {
118118
const channel = mock.channels._getChannel("test-channel");
119119

120120
await runCommand(
121-
["channels:presence:get-all", "test-channel", "--limit", "50"],
121+
["channels:presence:get", "test-channel", "--limit", "50"],
122122
import.meta.url,
123123
);
124124

@@ -144,7 +144,7 @@ describe("channels:presence:get-all command", () => {
144144
);
145145

146146
const { stdout } = await runCommand(
147-
["channels:presence:get-all", "test-channel", "--limit", "1", "--json"],
147+
["channels:presence:get", "test-channel", "--limit", "1", "--json"],
148148
import.meta.url,
149149
);
150150

@@ -162,7 +162,7 @@ describe("channels:presence:get-all command", () => {
162162
channel.presence.get.mockRejectedValue(new Error("API error"));
163163

164164
const { error } = await runCommand(
165-
["channels:presence:get-all", "test-channel"],
165+
["channels:presence:get", "test-channel"],
166166
import.meta.url,
167167
);
168168

@@ -180,7 +180,7 @@ describe("channels:presence:get-all command", () => {
180180
);
181181

182182
const { error } = await runCommand(
183-
["channels:presence:get-all", "nonexistent-channel"],
183+
["channels:presence:get", "nonexistent-channel"],
184184
import.meta.url,
185185
);
186186

test/unit/commands/channels/presence/update.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ describe("channels:presence:update command", () => {
5050
[
5151
"channels:presence:update",
5252
"test-channel",
53+
"--client-id",
54+
"test-client",
5355
"--data",
5456
'{"status":"away"}',
5557
],
@@ -72,6 +74,8 @@ describe("channels:presence:update command", () => {
7274
[
7375
"channels:presence:update",
7476
"test-channel",
77+
"--client-id",
78+
"test-client",
7579
"--data",
7680
'{"status":"away"}',
7781
],
@@ -89,6 +93,8 @@ describe("channels:presence:update command", () => {
8993
[
9094
"channels:presence:update",
9195
"test-channel",
96+
"--client-id",
97+
"test-client",
9298
"--data",
9399
'{"status":"away"}',
94100
"--json",
@@ -114,6 +120,8 @@ describe("channels:presence:update command", () => {
114120
[
115121
"channels:presence:update",
116122
"test-channel",
123+
"--client-id",
124+
"test-client",
117125
"--data",
118126
'{"status":"away"}',
119127
"--json",
@@ -135,6 +143,8 @@ describe("channels:presence:update command", () => {
135143
[
136144
"channels:presence:update",
137145
"test-channel",
146+
"--client-id",
147+
"test-client",
138148
"--data",
139149
"not-valid-json",
140150
],
@@ -158,6 +168,8 @@ describe("channels:presence:update command", () => {
158168
[
159169
"channels:presence:update",
160170
"test-channel",
171+
"--client-id",
172+
"test-client",
161173
"--data",
162174
'{"status":"away"}',
163175
],
@@ -178,6 +190,8 @@ describe("channels:presence:update command", () => {
178190
[
179191
"channels:presence:update",
180192
"test-channel",
193+
"--client-id",
194+
"test-client",
181195
"--data",
182196
'{"status":"away"}',
183197
],

0 commit comments

Comments
 (0)