Custom Commands

Learn how to create and use custom commands with Zonia

Creating Custom Commands

Custom commands allow you to create shortcuts for frequently used operations. Here's how to create them:

// Define a custom command
const customCommand = {
	name: "generate_report",
	description: "Generate a weekly report",
	template: `
		Create a detailed report for {project}
		Include:
		- Progress updates
		- Key metrics
		- Next steps
	`
};

// Register the command
zonia.registerCommand(customCommand);

// Use the command
const report = await zonia.executeCommand("generate_report", {
	project: "Website Redesign"
});

Command Types

Template Commands

  • • Pre-defined text templates
  • • Variable placeholders
  • • Customizable formatting
  • • Reusable across projects

Function Commands

  • • Custom JavaScript functions
  • • Complex logic handling
  • • API integrations
  • • Data processing

Advanced Usage

Command Chaining

// Chain multiple commands
const workflow = zonia.createWorkflow([
	{
		command: "analyze_data",
		params: { source: "sales_data" }
	},
	{
		command: "generate_report",
		params: { format: "pdf" }
	},
	{
		command: "send_email",
		params: { to: "team@company.com" }
	}
]);

// Execute workflow
await workflow.execute();

Best Practices

Do's

  • ✓ Use descriptive command names
  • ✓ Document command parameters
  • ✓ Include error handling
  • ✓ Test commands thoroughly

Don'ts

  • ✗ Create overly complex commands
  • ✗ Hardcode sensitive data
  • ✗ Skip input validation
  • ✗ Ignore error states