summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-12 01:24:01 +0200
committermo8it <mo8it@proton.me>2024-04-12 01:24:01 +0200
commit2a95a3e96644a0f769019204a518816c9f2e2aee (patch)
tree44a0f35cf3fc63d39346433af568451e501b4628 /src/main.rs
parent1e3745ccdf5ca41ae47d4f4d8594e8070df200a5 (diff)
Deal with long strings
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs65
1 files changed, 46 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs
index 7bc10ac..fdbb710 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -3,7 +3,6 @@ use clap::{Parser, Subcommand};
use std::{path::Path, process::exit};
mod app_state;
-mod consts;
mod embedded;
mod exercise;
mod init;
@@ -14,7 +13,6 @@ mod watch;
use self::{
app_state::AppState,
- consts::WELCOME,
exercise::InfoFile,
init::init,
list::list,
@@ -54,11 +52,7 @@ enum Subcommands {
fn main() -> Result<()> {
let args = Args::parse();
- which::which("cargo").context(
- "Failed to find `cargo`.
-Did you already install Rust?
-Try running `cargo --version` to diagnose the problem.",
- )?;
+ which::which("cargo").context(CARGO_NOT_FOUND_ERR)?;
let mut info_file = InfoFile::parse()?;
info_file.exercises.shrink_to_fit();
@@ -66,20 +60,11 @@ Try running `cargo --version` to diagnose the problem.",
if matches!(args.command, Some(Subcommands::Init)) {
init(&exercises).context("Initialization failed")?;
- println!(
- "\nDone initialization!\n
-Run `cd rustlings` to go into the generated directory.
-Then run `rustlings` for further instructions on getting started."
- );
+
+ println!("{POST_INIT_MSG}");
return Ok(());
} else if !Path::new("exercises").is_dir() {
- println!(
- "
-{WELCOME}
-
-The `exercises` directory wasn't found in the current directory.
-If you are just starting with Rustlings, run the command `rustlings init` to initialize it."
- );
+ println!("{PRE_INIT_MSG}");
exit(1);
}
@@ -118,3 +103,45 @@ If you are just starting with Rustlings, run the command `rustlings init` to ini
Ok(())
}
+
+const CARGO_NOT_FOUND_ERR: &str = "Failed to find `cargo`.
+Did you already install Rust?
+Try running `cargo --version` to diagnose the problem.";
+
+const PRE_INIT_MSG: &str = r"
+ welcome to...
+ _ _ _
+ _ __ _ _ ___| |_| (_)_ __ __ _ ___
+ | '__| | | / __| __| | | '_ \ / _` / __|
+ | | | |_| \__ \ |_| | | | | | (_| \__ \
+ |_| \__,_|___/\__|_|_|_| |_|\__, |___/
+ |___/
+
+The `exercises` directory wasn't found in the current directory.
+If you are just starting with Rustlings, run the command `rustlings init` to initialize it.";
+
+const POST_INIT_MSG: &str = "
+Done initialization!
+
+Run `cd rustlings` to go into the generated directory.
+Then run `rustlings` for further instructions on getting started.";
+
+const FENISH_LINE: &str = "+----------------------------------------------------+
+| You made it to the Fe-nish line! |
++-------------------------- ------------------------+
+ \\/\x1b[31m
+ ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒
+ ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
+ ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
+ ░░▒▒▒▒░░▒▒ ▒▒ ▒▒ ▒▒ ▒▒░░▒▒▒▒
+ ▓▓▓▓▓▓▓▓ ▓▓ ▓▓██ ▓▓ ▓▓██ ▓▓ ▓▓▓▓▓▓▓▓
+ ▒▒▒▒ ▒▒ ████ ▒▒ ████ ▒▒░░ ▒▒▒▒
+ ▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒
+ ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒
+ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
+ ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
+ ▒▒ ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒ ▒▒
+ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
+ ▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒▒
+ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒
+ ▒▒ ▒▒ ▒▒ ▒▒\x1b[0m";