1313import typer
1414
1515from aegis import __version__
16- from aegis .core .components import COMPONENTS , ComponentType , get_components_by_type
16+ from aegis .core .components import (
17+ COMPONENTS ,
18+ ComponentSpec ,
19+ ComponentType ,
20+ get_components_by_type ,
21+ )
1722from aegis .core .dependency_resolver import DependencyResolver
1823from aegis .core .template_generator import TemplateGenerator
1924
2227 name = "aegis" ,
2328 help = (
2429 "Aegis Stack CLI - Component generation and project management. "
25- "Available components: redis, worker, scheduler"
30+ "Available components: redis, worker, scheduler, database "
2631 ),
2732 add_completion = False ,
2833)
@@ -138,7 +143,7 @@ def init(
138143 "--components" ,
139144 "-c" ,
140145 callback = validate_and_resolve_components ,
141- help = "Comma-separated list of components (redis,worker,scheduler)" ,
146+ help = "Comma-separated list of components (redis,worker,scheduler,database )" ,
142147 ),
143148 interactive : bool = typer .Option (
144149 True ,
@@ -166,8 +171,8 @@ def init(
166171 Examples:\n
167172 - aegis init my-app\n
168173 - aegis init my-app --components redis,worker\n
169- - aegis init my-app --components redis,worker,scheduler --no-interactive\n
170- """
174+ - aegis init my-app --components redis,worker,scheduler,database --no-interactive\n
175+ """ # noqa
171176
172177 # Validate project name first
173178 validate_project_name (project_name )
@@ -304,6 +309,18 @@ def init(
304309 raise typer .Exit (1 )
305310
306311
312+ def get_interactive_infrastructure_components () -> list [ComponentSpec ]:
313+ """Get infrastructure components available for interactive selection."""
314+ # Get all infrastructure components
315+ infra_components = []
316+ for component_spec in COMPONENTS .values ():
317+ if component_spec .type == ComponentType .INFRASTRUCTURE :
318+ infra_components .append (component_spec )
319+
320+ # Sort by name for consistent ordering
321+ return sorted (infra_components , key = lambda x : x .name )
322+
323+
307324def interactive_component_selection () -> list [str ]:
308325 """Interactive component selection with dependency awareness."""
309326
@@ -313,20 +330,41 @@ def interactive_component_selection() -> list[str]:
313330
314331 selected = []
315332
316- # Infrastructure components
333+ # Get all infrastructure components from registry
334+ infra_components = get_interactive_infrastructure_components ()
335+
317336 typer .echo ("🏗️ Infrastructure Components:" )
318- if typer .confirm (" Add Redis (caching, message queues)?" ):
319- selected .append ("redis" )
320-
321- if "redis" in selected :
322- if typer .confirm (" Add worker infrastructure (background tasks)?" ):
323- selected .append ("worker" )
324- else :
325- if typer .confirm (" Add worker infrastructure? (will auto-add Redis)" ):
326- selected .extend (["redis" , "worker" ])
327-
328- if typer .confirm (" Add scheduler infrastructure (scheduled tasks)?" ):
329- selected .append ("scheduler" )
337+
338+ # Process components in a specific order to handle dependencies
339+ component_order = ["redis" , "worker" , "scheduler" , "database" ]
340+
341+ for component_name in component_order :
342+ # Find the component spec
343+ component_spec = next (
344+ (c for c in infra_components if c .name == component_name ), None
345+ )
346+ if not component_spec :
347+ continue # Skip if component doesn't exist in registry
348+
349+ # Handle special worker dependency logic
350+ if component_name == "worker" :
351+ if "redis" in selected :
352+ # Redis already selected, simple worker prompt
353+ prompt = f" Add { component_spec .description .lower ()} ?"
354+ if typer .confirm (prompt ):
355+ selected .append ("worker" )
356+ else :
357+ # Redis not selected, offer to add both
358+ prompt = (
359+ f" Add { component_spec .description .lower ()} ? (will auto-add Redis)"
360+ )
361+ if typer .confirm (prompt ):
362+ selected .extend (["redis" , "worker" ])
363+ else :
364+ # Standard prompt for other components
365+ prompt = f" Add { component_spec .description } ?"
366+ if typer .confirm (prompt ):
367+ selected .append (component_name )
330368
331369 return selected
332370
0 commit comments