use crate::{
cache::{Cache, models::Problem},
err::Error,
};
pub(crate) async fn populated_problems(cache: &Cache) -> Result<Vec<Problem>, Error> {
let problems = cache.get_problems()?;
if !problems.is_empty() {
return Ok(problems);
}
cache.clone().download_problems().await?;
let problems = cache.get_problems()?;
if problems.is_empty() {
return Err(Error::DownloadError("problems".into()));
}
Ok(problems)
}
pub(crate) fn ensure_plan_supported(plan: Option<&String>) -> Result<(), Error> {
#[cfg(not(feature = "pym"))]
if plan.is_some() {
return Err(anyhow::anyhow!(
"--plan needs the optional `pym` feature, which this build does not have. \
Reinstall with `cargo install leetctl --features pym`."
)
.into());
}
let _ = plan;
Ok(())
}
mod completions;
mod data;
mod edit;
mod exec;
mod list;
mod pick;
mod review;
mod sets;
mod stat;
mod test;
mod tui;
pub use completions::CompletionsArgs;
pub use data::DataArgs;
pub use edit::EditArgs;
pub use exec::ExecArgs;
pub use list::ListArgs;
pub use pick::PickArgs;
pub use review::ReviewArgs;
pub use sets::SetsArgs;
pub use stat::StatArgs;
pub use test::TestArgs;
pub use tui::TuiArgs;