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

***

# Function: getCommands()

> **getCommands**(`directory`): (`options`?) => `Promise`<`Command`\[]>

Defined in: commands.ts:67

Returns all commands from EventCatalog.

You can optionally specify if you want to get the latest version of the events.

## 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                                                    |
| ----------------------- | ------------------------------------------------------- |
| `options`?              | { `attachSchema`: `boolean`; `latestOnly`: `boolean`; } |
| `options.attachSchema`? | `boolean`                                               |
| `options.latestOnly`?   | `boolean`                                               |

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

`Promise`<`Command`\[]>

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

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

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

// Gets all commands (and versions) from the catalog
const commands = await getCommands();

// Gets all commands (only latest version) from the catalog
const commands = await getCommands({ latestOnly: true });

// Gets all commands with the schema attached
const commands = await getCommands({ attachSchema: true });
```
