CLI Framework (Topia)
Azu CLI is built on top of Topia, a modern, high-performance task automation framework built with Crystal. Topia provides the foundation for command parsing, task execution, and the overall CLI architecture.
Overview
Topia is a Crystal-powered task automation and build pipeline framework that transforms development workflows. It provides:
Code over Configuration - Write workflows in pure Crystal, no complex config files
High Performance - Built for speed with async operations, caching, and parallelism
Composable - Chain tasks, plugins, and commands like building blocks
Type Safe - Leverage Crystal's compile-time type checking for bulletproof workflows
Developer Friendly - Professional CLI, interactive modes, and comprehensive debugging tools
Core Components
Task System
Topia's task system is the foundation of Azu CLI's command execution:
# Simple command task
Topia.task("build")
.describe("Build the application")
.command("crystal build --release src/main.cr")
# Task with dependencies
Topia.task("test")
.describe("Run tests")
.depends_on("build")
.command("crystal spec")
# Task with file watching
Topia.task("dev")
.describe("Development server with hot reload")
.src("./src/**/*.cr")
.pipe(FileWatcher.new)
.command("crystal run src/main.cr")Command Execution
Topia provides robust command execution with error handling and output management:
Plugin System
Topia's plugin system allows Azu CLI to extend functionality through composable plugins:
CLI Architecture
Command Parsing
Topia provides automatic command-line argument parsing:
Subcommand Support
Topia enables hierarchical command structures:
Performance Features
Async Operations
Topia provides non-blocking operations for better performance:
Intelligent Caching
Topia provides automatic caching based on input file checksums and command signatures:
Parallel Execution
Topia supports concurrent task execution for improved performance:
Configuration Integration
Environment Variable Support
Topia integrates with Azu CLI's configuration system:
YAML Configuration
Topia supports YAML-based configuration:
Debugging and Monitoring
Enhanced Debugging
Topia provides comprehensive debugging capabilities:
Performance Metrics
Topia provides detailed performance insights:
Lifecycle Hooks
Plugin Lifecycle
Topia provides lifecycle hooks for plugins:
Integration with Azu CLI
Command Structure
Azu CLI uses Topia's command system for all CLI operations:
Error Handling
Topia provides robust error handling for Azu CLI:
Performance Benefits
Before Topia Integration
Build time: 45s
CPU usage: 15% (spinner)
Memory: Growing over time
Cache hits: 0%
After Topia Integration
Build time: 12s (with parallelism + caching)
CPU usage: <1% (async spinner)
Memory: Stable with cleanup
Cache hits: 85%+
Real-World Results
Medium project (50 files): 40s → 8s (5x faster)
Large project (200+ files): 3min → 45s (4x faster)
CI pipeline: 8min → 2min (4x faster)
Best Practices
Task Design
Keep tasks focused: Each task should have a single responsibility
Use dependencies: Leverage Topia's dependency system for proper ordering
Enable caching: Use caching for expensive operations
Profile performance: Use Topia's profiling tools to identify bottlenecks
Plugin Development
Follow the interface: Implement
Topia::BasePlugincorrectlyHandle errors gracefully: Provide meaningful error messages
Use lifecycle hooks: Implement proper setup and cleanup
Document your plugin: Provide clear documentation for users
Configuration
Use environment variables: For sensitive configuration
Provide defaults: Always provide sensible default values
Validate configuration: Use Topia's validation features
Keep it simple: Avoid overly complex configuration structures
Related Documentation
Topia Repository - Official Topia documentation
Architecture Overview - Overall Azu CLI architecture
Generator System - Code generation architecture
Configuration System - Configuration management
Plugin System - Plugin development guide
Last updated