Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion tmc-langs-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ base64 = "0.13"
schemars = "0.8"
thiserror = "1"
toml = "0.5"
heim = { version = "0.1.0-beta.3", features = ["disk"] }
smol = "1"

[dev-dependencies]
Expand Down
23 changes: 23 additions & 0 deletions tmc-langs-cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod tmc_config;
pub use self::credentials::Credentials;
pub use self::projects_config::{CourseConfig, Exercise, ProjectsConfig};
pub use self::tmc_config::{ConfigValue, TmcConfig};
use crate::output::LocalExercise;

use anyhow::{Context, Error};
use std::env;
Expand All @@ -20,3 +21,25 @@ fn get_tmc_dir(client_name: &str) -> Result<PathBuf, Error> {
};
Ok(config_dir.join(format!("tmc-{}", client_name)))
}

pub fn list_local_course_exercises(
client_name: &str,
course_slug: &str,
) -> Result<Vec<LocalExercise>, anyhow::Error> {
let projects_dir = TmcConfig::load(client_name)?.projects_dir;
let mut projects_config = ProjectsConfig::load(&projects_dir)?;

let exercises = projects_config
.courses
.remove(course_slug)
.map(|cc| cc.exercises)
.unwrap_or_default();
let mut local_exercises: Vec<LocalExercise> = vec![];
for (exercise_slug, _) in exercises {
local_exercises.push(LocalExercise {
exercise_path: projects_dir.join(course_slug).join(&exercise_slug),
exercise_slug,
})
}
Ok(local_exercises)
}
Loading