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

***

# Function: addExampleToCommand()

> **addExampleToCommand**(`directory`): (`id`, `example`, `version`?) => `Promise`<`void`>

Defined in: commands.ts:336

Add an example file to a 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`                                       |
| `example`           | { `content`: `string`; `fileName`: `string`; } |
| `example.content`   | `string`                                       |
| `example.fileName`? | `string`                                       |
| `version`?          | `string`                                       |

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

`Promise`<`void`>

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

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

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

await addExampleToCommand('UpdateInventory', { content: '{"id": "123"}', fileName: 'basic.json' });
await addExampleToCommand('UpdateInventory', { content: '{"id": "123"}', fileName: 'basic.json' }, '0.0.1');
```
