- 55 CLI files: handlers/, aitbc_cli/commands/, cli/core/, cli/utils/, top-level scripts
- Click-based files: print() -> click.echo()
- Library modules: print() -> logger.info/error/warning
- Fixed pre-existing indentation bugs in monitor.py dashboard function
- Fixed bare print() -> logger.info('') in chain_manager.py
- 0 remaining print() in production CLI code
- All files compile cleanly
63 lines
1.9 KiB
Python
63 lines
1.9 KiB
Python
"""Workflow command handlers for AITBC CLI."""
|
|
|
|
import json
|
|
import logging
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
|
|
def handle_workflow_create(args, render_mapping):
|
|
"""Handle workflow create command."""
|
|
name = getattr(args, "name", None) or "unnamed-workflow"
|
|
template = getattr(args, "template", "custom")
|
|
steps = getattr(args, "steps", 5)
|
|
|
|
workflow_data = {
|
|
"workflow_id": f"workflow_{int(__import__('time').time())}",
|
|
"name": name,
|
|
"template": template,
|
|
"status": "created",
|
|
"steps": steps,
|
|
"estimated_duration": f"{steps * 2}-{steps * 3} minutes"
|
|
}
|
|
|
|
logger.info(f"Workflow created: {workflow_data['workflow_id']}")
|
|
render_mapping("Workflow:", workflow_data)
|
|
|
|
|
|
def handle_workflow_schedule(args, render_mapping):
|
|
"""Handle workflow schedule command."""
|
|
name = getattr(args, "name", None)
|
|
cron = getattr(args, "cron", None)
|
|
command = getattr(args, "command", None)
|
|
|
|
schedule_data = {
|
|
"schedule_id": f"schedule_{int(__import__('time').time())}",
|
|
"workflow_name": name,
|
|
"cron_expression": cron,
|
|
"command": command,
|
|
"status": "scheduled",
|
|
"next_run": "pending"
|
|
}
|
|
|
|
logger.info(f"Workflow scheduled: {schedule_data['schedule_id']}")
|
|
render_mapping("Schedule:", schedule_data)
|
|
|
|
|
|
def handle_workflow_monitor(args, output_format, render_mapping):
|
|
"""Handle workflow monitor command."""
|
|
name = getattr(args, "name", None)
|
|
|
|
monitor_data = {
|
|
"status": "active",
|
|
"workflows_running": 2,
|
|
"workflows_completed": 15,
|
|
"workflows_failed": 0,
|
|
"last_check": __import__('datetime').datetime.now().isoformat()
|
|
}
|
|
|
|
if output_format(args) == "json":
|
|
logger.info(json.dumps(monitor_data, indent=2))
|
|
else:
|
|
render_mapping("Workflow Monitor:", monitor_data)
|