rustlings/src/dev.rs

35 lines
805 B
Rust
Raw Normal View History

use anyhow::{bail, Context, Result};
2024-04-16 00:54:57 +03:00
use clap::Subcommand;
use crate::DEVELOPING_OFFICIAL_RUSTLINGS;
2024-04-16 00:54:57 +03:00
mod check;
mod init;
2024-04-17 16:55:50 +03:00
mod update;
2024-04-16 00:54:57 +03:00
#[derive(Subcommand)]
pub enum DevCommands {
Init,
Check,
2024-04-17 16:55:50 +03:00
Update,
2024-04-16 00:54:57 +03:00
}
impl DevCommands {
2024-04-17 16:55:50 +03:00
pub fn run(self) -> Result<()> {
2024-04-16 00:54:57 +03:00
match self {
DevCommands::Init => {
if DEVELOPING_OFFICIAL_RUSTLINGS {
bail!("Disabled while developing the official Rustlings");
}
init::init().context(INIT_ERR)
}
2024-04-17 16:55:50 +03:00
DevCommands::Check => check::check(),
DevCommands::Update => update::update(),
2024-04-16 00:54:57 +03:00
}
}
}
2024-04-16 04:08:45 +03:00
const INIT_ERR: &str = "Initialization failed.
After resolving the issue, delete the `rustlings` directory (if it was created) and try again";