Copy as Markdown[View as Markdown](/docs/sdk/functions/getCommand.md)

***

# Function: getCommand()

> **getCommand**(`directory`): (`id`, `version`?, `options`?) => `Promise`<`Command`>

Defined in: commands.ts:41

Returns a command from EventCatalog.

You can optionally specify a version to get a specific version of the command

## Parameters[​](#parameters "Direct link to Parameters")

| Parameter   | Type     |
| ----------- | -------- |
| `directory` | `string` |

## Returns[​](#returns "Direct link to Returns")

`Function`

### Parameters[​](#parameters-1 "Direct link to Parameters")

| Parameter               | Type                           |
| ----------------------- | ------------------------------ |
| `id`                    | `string`                       |
| `version`?              | `string`                       |
| `options`?              | { `attachSchema`: `boolean`; } |
| `options.attachSchema`? | `boolean`                      |

### Returns[​](#returns-1 "Direct link to Returns")

`Promise`<`Command`>

## Example[​](#example "Direct link to Example")

```
import utils from '@eventcatalog/utils';

const { getCommand } = utils('/path/to/eventcatalog');

// Gets the latest version of the command
const command = await getCommand('UpdateInventory');

// Gets a version of the command
const command = await getCommand('UpdateInventory', '0.0.1');

// Gets the command with the schema attached
const command = await getCommand('UpdateInventory', '0.0.1', { attachSchema: true });
```
