async fn start_task(
roadmap_path: &Path,
task_id: &str,
create_branch: bool,
config: &RoadmapConfig,
) -> Result<()> {
println!("🚀 Starting task {task_id}");
let mut roadmap = Roadmap::from_file(roadmap_path)?;
roadmap.update_task_status(task_id, TaskStatus::InProgress)?;
roadmap.to_file(roadmap_path)?;
println!("✅ Task {task_id} status updated to: 🚧 In Progress");
if create_branch && config.git.create_branches {
let branch_name = config
.git
.branch_pattern
.replace("{task_id}", &task_id.to_lowercase());
println!("🌿 Creating branch: {branch_name}");
std::process::Command::new("git")
.args(["checkout", "-b", &branch_name])
.output()
.context("Failed to create git branch")?;
println!("✅ Branch created and checked out: {branch_name}");
}
if let Some(task) = roadmap.get_task(task_id) {
println!("\n📋 Task Details:");
println!(" ID: {}", task.id);
println!(" Description: {}", task.description);
println!(" Complexity: {:?}", task.complexity);
println!(" Priority: {:?}", task.priority);
}
Ok(())
}
async fn complete_task(
roadmap_path: &Path,
task_id: &str,
skip_quality_check: bool,
config: &RoadmapConfig,
) -> Result<()> {
println!("🏁 Completing task {task_id}");
if !skip_quality_check && config.enforce_quality_gates {
println!("🔍 Running quality checks...");
quality_check(task_id, config).await?;
}
let mut roadmap = Roadmap::from_file(roadmap_path)?;
roadmap.update_task_status(task_id, TaskStatus::Completed)?;
roadmap.to_file(roadmap_path)?;
println!("✅ Task {task_id} completed successfully");
if config.git.require_quality_check {
let message = config
.git
.commit_pattern
.replace("{task_id}", task_id)
.replace("{message}", "Complete implementation");
println!("📝 Creating commit: {message}");
std::process::Command::new("git")
.args(["add", "-A"])
.output()?;
std::process::Command::new("git")
.args(["commit", "-m", &message])
.output()?;
println!("✅ Changes committed");
}
Ok(())
}
#[allow(dead_code)]
fn handle_start(task_id: String, create_branch: bool) -> Result<()> {
if !task_id.starts_with("PMAT-") {
anyhow::bail!("Invalid task ID format. Expected PMAT-XXXX");
}
println!("🚀 Starting work on task: {task_id}");
if create_branch {
let branch_name = format!("feature/{}", task_id.to_lowercase());
println!("🌿 Creating branch: {branch_name}");
let result = std::process::Command::new("git")
.args(["checkout", "-b", &branch_name])
.output();
match result {
Ok(output) if output.status.success() => {
println!("✅ Branch created successfully");
}
Ok(_) => {
println!("⚠️ Branch creation attempted but may have failed");
}
Err(_) => {
println!("⚠️ Git not available or branch creation failed");
}
}
}
println!("✅ Task {task_id} is now active");
Ok(())
}