dojo_cli/commands/
update_curriculum.rs1use 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 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 let config = Config::load()?;
18 let api_token = &config.api_token;
19
20 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}