dojo_cli/commands/
update_curriculum.rs

1use crate::config::Config;
2use clap::ArgMatches;
3
4pub async fn handle_update_curriculum_command(
5    sub_matches: &ArgMatches,
6) -> Result<(), Box<dyn std::error::Error>> {
7    // Get the optional version parameter
8    let target_version = sub_matches.get_one::<String>("version").map(|s| s.as_str());
9
10    if let Some(version) = target_version {
11        println!("🔄 Updating curriculum version to: {}...", version);
12    } else {
13        println!("🔄 Checking for curriculum version updates...");
14    }
15
16    // Load existing config
17    let config = Config::load()?;
18    let api_token = &config.api_token;
19
20    // Update curriculum version
21    match Config::update_curriculum_version(api_token, target_version).await {
22        Ok(new_version) => {
23            println!("✅ Curriculum version updated successfully!");
24            println!("📚 New curriculum version: {}", new_version);
25        }
26        Err(e) => {
27            println!("❌ Failed to update curriculum version: {}", e);
28            return Err(e);
29        }
30    }
31
32    Ok(())
33}