diff options
| author | mo8it <mo8it@proton.me> | 2024-03-31 16:55:33 +0200 |
|---|---|---|
| committer | mo8it <mo8it@proton.me> | 2024-03-31 16:55:33 +0200 |
| commit | 82b563f1654860ba3590d91ec3c0f321e3130ae2 (patch) | |
| tree | c5a807fe8d9d7794f9d60148734af15625dddc72 /src/main.rs | |
| parent | b711dd692afaf42830efb04c491616d3f069fbdf (diff) | |
Use Cargo instead of rustc
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/src/main.rs b/src/main.rs index 1926f6a..1c736f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,20 +4,18 @@ use crate::verify::verify; use anyhow::{Context, Result}; use clap::{Parser, Subcommand}; use console::Emoji; -use embedded::EMBEDDED_FILES; use notify_debouncer_mini::notify::{self, RecursiveMode}; use notify_debouncer_mini::{new_debouncer, DebouncedEventKind}; use shlex::Shlex; use std::ffi::OsStr; -use std::fs; -use std::io::{self, prelude::*}; +use std::io::{BufRead, Write}; use std::path::Path; use std::process::{exit, Command}; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::mpsc::{channel, RecvTimeoutError}; use std::sync::{Arc, Mutex}; -use std::thread; use std::time::Duration; +use std::{io, thread}; #[macro_use] mod ui; @@ -94,21 +92,16 @@ fn main() -> Result<()> { println!("\n{WELCOME}\n"); } - if which::which("rustc").is_err() { - println!("We cannot find `rustc`."); - println!("Try running `rustc --version` to diagnose your problem."); - println!("For instructions on how to install Rust, check the README."); + if which::which("cargo").is_err() { + println!( + "Failed to find `cargo`. +Did you already install Rust? +Try running `cargo --version` to diagnose the problem." + ); std::process::exit(1); } - // Read a local `info.toml` if it exists. Mainly to let the tests work for now. - let exercises = if let Ok(file_content) = fs::read_to_string("info.toml") { - toml_edit::de::from_str::<ExerciseList>(&file_content) - } else { - toml_edit::de::from_str::<ExerciseList>(EMBEDDED_FILES.info_toml_content) - } - .context("Failed to parse `info.toml`")? - .exercises; + let exercises = ExerciseList::parse()?.exercises; if matches!(args.command, Some(Subcommands::Init)) { init::init_rustlings(&exercises).context("Initialization failed")?; |
