CLI Commands Reference
Complete reference for all Branded Barber CLI commands. Use these commands to manage your data, seed databases, import content, and run diagnostics.
Usage
Run commands using the Nx target (development) or the global CLI (production):
# Development (Nx monorepo) nx run branded-barber-cli:cli -- <command> [options] # Production (global install) branded-barber <command> [options]
1. List Resources
View resources in the database for a specific tenant.
List Barbers
nx run branded-barber-cli:cli -- list barbers -t <tenant-id> # or branded-barber list barbers -t <tenant-id>
List Services
nx run branded-barber-cli:cli -- list services -t <tenant-id> branded-barber list services -t <tenant-id>
List Content
nx run branded-barber-cli:cli -- list content -t <tenant-id> branded-barber list content -t <tenant-id>
List Hours
nx run branded-barber-cli:cli -- list hours -t <tenant-id> branded-barber list hours -t <tenant-id>
List Contact
nx run branded-barber-cli:cli -- list contact -t <tenant-id> branded-barber list contact -t <tenant-id>
2. Create Resources
Add new resources with validation.
Create Barber
nx run branded-barber-cli:cli -- create barber -n "Name" --title "Title" -t <tenant-id> branded-barber create barber -n "John Doe" --title "Master Barber" -t tenant-1
Create Service
nx run branded-barber-cli:cli -- create service -n "Name" -p 25 -d 30 -t <tenant-id> branded-barber create service -n "Haircut" -p 30 -d 30 -t tenant-1
Options: -n name, -p price, -d duration (minutes), -t tenant ID
3. Delete Resources
Remove resources from the database.
Delete Barber
nx run branded-barber-cli:cli -- delete barber <id> -t <tenant-id> branded-barber delete barber 507f1f77bcf86cd799439011 -t tenant-1
Delete Service
nx run branded-barber-cli:cli -- delete service <id> -t <tenant-id> branded-barber delete service 507f1f77bcf86cd799439011 -t tenant-1
4. Database Management
Seed Database
# Seed with baseline data nx run branded-barber-cli:cli -- seed branded-barber seed # Seed with dry-run (preview changes) nx run branded-barber-cli:cli -- seed --dry-run branded-barber seed --dry-run
Inspect Database
# View database statistics and collections nx run branded-barber-cli:cli -- db inspect branded-barber db inspect
Shows collection counts, database size, and connection status.
Migrate Data
# Migrate data between tenants (use --dry-run to test first) nx run branded-barber-cli:cli -- migrate <source-tenant> <target-tenant> --dry-run branded-barber migrate tenant-1 tenant-2 --dry-run # Execute migration branded-barber migrate tenant-1 tenant-2
--dry-run first to preview what will be migrated.5. System Diagnostics
Check Connection
# Check API connection and health nx run branded-barber-cli:cli -- doctor connection -t <tenant-id> branded-barber doctor connection -t tenant-1
Verifies database connectivity, API health, and tenant configuration.
6. Testing
Run CRUD Tests
# Run integration tests (CRUD operations) nx run branded-barber-cli:cli -- test crud -t <tenant-id> branded-barber test crud -t tenant-1
Tests create, read, update, and delete operations for all resource types.
Run Smoke Tests
# Run smoke tests for gallery and image functionality nx run branded-barber-cli:cli -- test smoke --tenant-id=<tenant-id> --api-url=<api-url> branded-barber test smoke --tenant-id=not-grumpy-barber --api-url=http://localhost:4402/api/v1
End-to-end tests verifying API health, gallery endpoints, image accessibility, Cloudinary integration, and database connectivity.
make smoke-test-platform for a quick smoke test with default settings.7. Import Commands
Import from Instagram
# Import latest 20 posts (default) nx run branded-barber-cli:cli -- import instagram -t <tenant-id> branded-barber import instagram -t tenant-1 # Import specific number of posts branded-barber import instagram -t tenant-1 --limit 50 # Dry run to preview branded-barber import instagram -t tenant-1 --dry-run
Requires INSTAGRAM_ACCESS_TOKEN and Cloudinary credentials. See the Instagram Import Guide for setup instructions.
Import Mock Data
# Import mock data for testing (uses Unsplash images) nx run branded-barber-cli:cli -- import mock -t <tenant-id> branded-barber import mock -t tenant-1 # Skip Cloudinary upload (faster, uses Unsplash URLs directly) branded-barber import mock -t tenant-1 --no-upload
Useful for testing and development. Creates sample gallery items with mock images.
make cli-import-mock TENANT_ID=not-grumpy-barber for quick test data.Import from Local Directory
# Import images from a local directory nx run branded-barber-cli:cli -- import local -t <tenant-id> --path <directory> branded-barber import local -t tenant-1 --path ./images
Uploads images from a local directory to Cloudinary and creates gallery items.
Common Options
Global Options: -t, --tenant-id <id> Tenant ID (required for most commands) -h, --help Display help for command --version Show version number Environment Variables: MONGO_URI MongoDB connection string API_URL API base URL (default: http://localhost:4402/api/v1) CLOUDINARY_CLOUD_NAME Cloudinary cloud name CLOUDINARY_API_KEY Cloudinary API key CLOUDINARY_API_SECRET Cloudinary API secret INSTAGRAM_ACCESS_TOKEN Instagram access token (for import)
Next Steps
- Read the Installation Guide for setup instructions
- Set up Instagram Import to sync your portfolio
- Run
branded-barber doctor connectionto verify your setup