Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,12 @@ $ ably-interactive
* [`ably rooms typing keystroke ROOM`](#ably-rooms-typing-keystroke-room)
* [`ably rooms typing subscribe ROOM`](#ably-rooms-typing-subscribe-room)
* [`ably spaces`](#ably-spaces)
* [`ably spaces create SPACE_NAME`](#ably-spaces-create-space_name)
* [`ably spaces cursors`](#ably-spaces-cursors)
* [`ably spaces cursors get-all SPACE_NAME`](#ably-spaces-cursors-get-all-space_name)
* [`ably spaces cursors set SPACE_NAME`](#ably-spaces-cursors-set-space_name)
* [`ably spaces cursors subscribe SPACE_NAME`](#ably-spaces-cursors-subscribe-space_name)
* [`ably spaces get SPACE_NAME`](#ably-spaces-get-space_name)
* [`ably spaces list`](#ably-spaces-list)
* [`ably spaces locations`](#ably-spaces-locations)
* [`ably spaces locations get-all SPACE_NAME`](#ably-spaces-locations-get-all-space_name)
Expand All @@ -215,10 +217,12 @@ $ ably-interactive
* [`ably spaces locks subscribe SPACE_NAME`](#ably-spaces-locks-subscribe-space_name)
* [`ably spaces members`](#ably-spaces-members)
* [`ably spaces members enter SPACE_NAME`](#ably-spaces-members-enter-space_name)
* [`ably spaces members get-all SPACE_NAME`](#ably-spaces-members-get-all-space_name)
* [`ably spaces members subscribe SPACE_NAME`](#ably-spaces-members-subscribe-space_name)
* [`ably spaces occupancy`](#ably-spaces-occupancy)
* [`ably spaces occupancy get SPACE_NAME`](#ably-spaces-occupancy-get-space_name)
* [`ably spaces occupancy subscribe SPACE_NAME`](#ably-spaces-occupancy-subscribe-space_name)
* [`ably spaces subscribe SPACE_NAME`](#ably-spaces-subscribe-space_name)
* [`ably stats`](#ably-stats)
* [`ably stats account`](#ably-stats-account)
* [`ably stats app [ID]`](#ably-stats-app-id)
Expand Down Expand Up @@ -4395,21 +4399,61 @@ DESCRIPTION
EXAMPLES
$ ably spaces list

$ ably spaces get my-space

$ ably spaces create my-space

$ ably spaces subscribe my-space

$ ably spaces members enter my-space

$ ably spaces locations set my-space

COMMANDS
ably spaces create Create a new space
ably spaces cursors Commands for interacting with Cursors in Ably Spaces
ably spaces get Get the current state of a space
ably spaces list List active spaces
ably spaces locations Commands for location management in Ably Spaces
ably spaces locks Commands for component locking in Ably Spaces
ably spaces members Commands for managing members in Ably Spaces
ably spaces occupancy Commands for working with occupancy in Ably Spaces
ably spaces subscribe Subscribe to space update events
```

_See code: [src/commands/spaces/index.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/index.ts)_

## `ably spaces create SPACE_NAME`

Create a new space

```
USAGE
$ ably spaces create SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>]

ARGUMENTS
SPACE_NAME Name of the space to create

FLAGS
-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.
--json Output in JSON format
--pretty-json Output in colorized JSON format

DESCRIPTION
Create a new space

Comment on lines +4426 to +4446
EXAMPLES
$ ably spaces create my-space

$ ably spaces create my-space --json

$ ably spaces create my-space --client-id my-client
```

_See code: [src/commands/spaces/create.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/create.ts)_

## `ably spaces cursors`

Commands for interacting with Cursors in Ably Spaces
Expand Down Expand Up @@ -4545,6 +4589,35 @@ EXAMPLES

_See code: [src/commands/spaces/cursors/subscribe.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/cursors/subscribe.ts)_

## `ably spaces get SPACE_NAME`

Get the current state of a space

```
USAGE
$ ably spaces get SPACE_NAME [-v] [--json | --pretty-json]

ARGUMENTS
SPACE_NAME Name of the space to get

FLAGS
-v, --verbose Output verbose logs
--json Output in JSON format
--pretty-json Output in colorized JSON format

DESCRIPTION
Get the current state of a space

EXAMPLES
$ ably spaces get my-space

$ ably spaces get my-space --json

$ ably spaces get my-space --pretty-json
```

_See code: [src/commands/spaces/get.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/get.ts)_

## `ably spaces list`

List active spaces
Expand Down Expand Up @@ -4909,6 +4982,37 @@ EXAMPLES

_See code: [src/commands/spaces/members/enter.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/enter.ts)_

## `ably spaces members get-all SPACE_NAME`

Get all members in a space

```
USAGE
$ ably spaces members get-all SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>]

ARGUMENTS
SPACE_NAME Name of the space to get members from

FLAGS
-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.
--json Output in JSON format
--pretty-json Output in colorized JSON format

DESCRIPTION
Get all members in a space

EXAMPLES
$ ably spaces members get-all my-space

$ ably spaces members get-all my-space --json

$ ably spaces members get-all my-space --pretty-json
```

_See code: [src/commands/spaces/members/get-all.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/members/get-all.ts)_

## `ably spaces members subscribe SPACE_NAME`

Subscribe to member presence events in a space
Expand Down Expand Up @@ -5023,6 +5127,40 @@ EXAMPLES

_See code: [src/commands/spaces/occupancy/subscribe.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/occupancy/subscribe.ts)_

## `ably spaces subscribe SPACE_NAME`

Subscribe to space update events

```
USAGE
$ ably spaces subscribe SPACE_NAME [-v] [--json | --pretty-json] [--client-id <value>] [-D <value>]

ARGUMENTS
SPACE_NAME Name of the space to subscribe to

FLAGS
-D, --duration=<value> Automatically exit after N seconds
-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.
--json Output in JSON format
--pretty-json Output in colorized JSON format

DESCRIPTION
Subscribe to space update events

EXAMPLES
$ ably spaces subscribe my-space

$ ably spaces subscribe my-space --json

$ ably spaces subscribe my-space --pretty-json

$ ably spaces subscribe my-space --duration 30
```

_See code: [src/commands/spaces/subscribe.ts](https://github.com/ably/ably-cli/blob/v0.17.0/src/commands/spaces/subscribe.ts)_

## `ably stats`

View statistics for your Ably account or apps
Expand Down
55 changes: 55 additions & 0 deletions src/commands/spaces/create.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Args } from "@oclif/core";

import { productApiFlags, clientIdFlag } from "../../flags.js";
import { SpacesBaseCommand } from "../../spaces-base-command.js";
import {
formatProgress,
formatResource,
formatSuccess,
} from "../../utils/output.js";

export default class SpacesCreate extends SpacesBaseCommand {
static override args = {
space_name: Args.string({
description: "Name of the space to create",
required: true,
}),
};

static override description = "Create a new space";

static override examples = [
"$ ably spaces create my-space",
"$ ably spaces create my-space --json",
"$ ably spaces create my-space --client-id my-client",
];

static override flags = {
...productApiFlags,
...clientIdFlag,
};

async run(): Promise<void> {
const { args, flags } = await this.parse(SpacesCreate);
const spaceName = args.space_name;

try {
if (!this.shouldOutputJson(flags)) {
this.log(formatProgress(`Creating space ${formatResource(spaceName)}`));
}

await this.initializeSpace(flags, spaceName, {
enterSpace: false,
setupConnectionLogging: false,
});

if (this.shouldOutputJson(flags)) {
this.logJsonResult({ space: { name: spaceName } }, flags);
} else {
this.log(formatSuccess(`Space ${formatResource(spaceName)} created.`));
}
Comment on lines +19 to +50
} catch (error) {
this.fail(error, flags, "spaceCreate");
}
}
}
Loading
Loading