EventCatalog CLI
The EventCatalog CLI allows you to interact with your EventCatalog directly from the command line. Execute any SDK function without writing code.
Installation​
You can run the CLI directly using npx without installing:
npx @eventcatalog/sdk <function> [args...]
Or install globally:
npm install -g @eventcatalog/sdk
Then use the eventcatalog command:
eventcatalog <function> [args...]
Basic Usage​
Specifying the catalog directory​
By default, the CLI uses the current directory. Use --dir to specify a different path:
npx @eventcatalog/sdk --dir /path/to/catalog getEvents
Listing available functions​
npx @eventcatalog/sdk list
Getting help​
npx @eventcatalog/sdk --help
Output Format​
All commands output JSON, making it easy to pipe to other tools like jq:
# Get all events and extract IDs
npx @eventcatalog/sdk getEvents | jq '.[].id'
# Count total events
npx @eventcatalog/sdk getEvents | jq 'length'
# Filter events by version
npx @eventcatalog/sdk getEvents | jq '.[] | select(.version == "1.0.0")'
Argument Types​
Arguments are automatically parsed:
| Type | Format | Example |
|---|---|---|
| String | Plain text or quoted | "OrderCreated" |
| Number | Numeric value | 42 or 3.14 |
| Boolean | true or false | true |
| JSON Object | '{...}' | '{"id":"test","version":"1.0.0"}' |
| JSON Array | '[...]' | '["item1","item2"]' |
Quick Examples​
Read operations​
# Get a specific event
npx @eventcatalog/sdk getEvent "OrderCreated"
# Get all services (latest versions only)
npx @eventcatalog/sdk getServices '{"latestOnly":true}'
# Check if a version exists
npx @eventcatalog/sdk eventHasVersion "OrderCreated" "1.0.0"
Write operations​
# Create a new event
npx @eventcatalog/sdk writeEvent '{"id":"OrderCreated","name":"Order Created","version":"1.0.0","markdown":"# Order Created Event"}'
# Add a service to a domain
npx @eventcatalog/sdk addServiceToDomain "Orders" '{"id":"OrderService","version":"1.0.0"}'
Delete operations​
# Remove an event by ID
npx @eventcatalog/sdk rmEventById "OrderCreated"
# Remove a specific version
npx @eventcatalog/sdk rmEventById "OrderCreated" "1.0.0"
Version operations​
# Version an event (move current to versioned directory)
npx @eventcatalog/sdk versionEvent "OrderCreated"