Skip to main content

Commands CLI Commands

Manage commands in your EventCatalog from the command line.

getCommand​

Returns a command from EventCatalog by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command to retrieve
versionstringNoSpecific version to retrieve (supports semver)

Examples:

# Get the latest command
npx @eventcatalog/sdk getCommand "CreateOrder"

# Get a specific version
npx @eventcatalog/sdk getCommand "CreateOrder" "1.0.0"

getCommands​

Returns all commands from EventCatalog

Arguments:

NameTypeRequiredDescription
optionsjsonNoOptions: {latestOnly?, attachSchema?}

Examples:

# Get all commands
npx @eventcatalog/sdk getCommands

writeCommand​

Writes a command to EventCatalog

Arguments:

NameTypeRequiredDescription
commandjsonYesCommand object with id, name, version, and markdown
optionsjsonNoOptions: {path?, override?, versionExistingContent?}

writeCommandToService​

Writes a command to a specific service

Arguments:

NameTypeRequiredDescription
commandjsonYesCommand object
servicejsonYesService reference: {id, version?}
optionsjsonNoOptions: {path?, format?, override?}

rmCommand​

Removes a command by its path

Arguments:

NameTypeRequiredDescription
pathstringYesPath to the command

Examples:

# Remove a command
npx @eventcatalog/sdk rmCommand "/CreateOrder"

rmCommandById​

Removes a command by its ID

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command to remove
versionstringNoSpecific version to remove

Examples:

# Remove a command
npx @eventcatalog/sdk rmCommandById "CreateOrder"

versionCommand​

Moves the current command to a versioned directory

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command to version

Examples:

# Version a command
npx @eventcatalog/sdk versionCommand "CreateOrder"

addFileToCommand​

Adds a file to a command

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command
filejsonYesFile object: {content, fileName}
versionstringNoSpecific version

addSchemaToCommand​

Adds a schema to a command

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command
schemajsonYesSchema object: {schema, fileName}
versionstringNoSpecific version

commandHasVersion​

Checks if a specific version of a command exists

Arguments:

NameTypeRequiredDescription
idstringYesThe ID of the command
versionstringYesVersion to check

Examples:

# Check if version exists
npx @eventcatalog/sdk commandHasVersion "CreateOrder" "1.0.0"