Skip to content

Commit f78c480

Browse files
committed
fix(cli): Move long text strings into constants.
1 parent 91530f5 commit f78c480

File tree

2 files changed

+64
-65
lines changed

2 files changed

+64
-65
lines changed

default_out.txt

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main.rs

Lines changed: 64 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,7 @@ fn main() {
107107
}
108108

109109
if args.nested.is_none() {
110-
println!();
111-
println!(r#" welcome to... "#);
112-
println!(r#" _ _ _ "#);
113-
println!(r#" _ __ _ _ ___| |_| (_)_ __ __ _ ___ "#);
114-
println!(r#" | '__| | | / __| __| | | '_ \ / _` / __| "#);
115-
println!(r#" | | | |_| \__ \ |_| | | | | | (_| \__ \ "#);
116-
println!(r#" |_| \__,_|___/\__|_|_|_| |_|\__, |___/ "#);
117-
println!(r#" |___/ "#);
118-
println!();
110+
println!("\n{}\n", WELCOME);
119111
}
120112

121113
if !Path::new("info.toml").exists() {
@@ -139,8 +131,7 @@ fn main() {
139131
let verbose = args.nocapture;
140132

141133
let command = args.nested.unwrap_or_else(|| {
142-
let text = fs::read_to_string("default_out.txt").unwrap();
143-
println!("{}", text);
134+
println!("{}\n", DEFAULT_OUT);
144135
std::process::exit(0);
145136
});
146137
match command {
@@ -229,35 +220,7 @@ fn main() {
229220
"{emoji} All exercises completed! {emoji}",
230221
emoji = Emoji("🎉", "★")
231222
);
232-
println!();
233-
println!("+----------------------------------------------------+");
234-
println!("| You made it to the Fe-nish line! |");
235-
println!("+-------------------------- ------------------------+");
236-
println!(" \\/ ");
237-
println!(" ▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒ ");
238-
println!(" ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ ");
239-
println!(" ▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒ ");
240-
println!(" ░░▒▒▒▒░░▒▒ ▒▒ ▒▒ ▒▒ ▒▒░░▒▒▒▒ ");
241-
println!(" ▓▓▓▓▓▓▓▓ ▓▓ ▓▓██ ▓▓ ▓▓██ ▓▓ ▓▓▓▓▓▓▓▓ ");
242-
println!(" ▒▒▒▒ ▒▒ ████ ▒▒ ████ ▒▒░░ ▒▒▒▒ ");
243-
println!(" ▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒ ");
244-
println!(" ▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒ ");
245-
println!(" ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ");
246-
println!(" ▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒ ");
247-
println!(" ▒▒ ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒ ▒▒ ");
248-
println!(" ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ");
249-
println!(" ▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒▒ ");
250-
println!(" ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ");
251-
println!(" ▒▒ ▒▒ ▒▒ ▒▒ ");
252-
println!();
253-
println!("We hope you enjoyed learning about the various aspects of Rust!");
254-
println!(
255-
"If you noticed any issues, please don't hesitate to report them to our repo."
256-
);
257-
println!("You can also contribute your own exercises to help the greater community!");
258-
println!();
259-
println!("Before reporting an issue or contributing, please read our guidelines:");
260-
println!("https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md");
223+
println!("\n{}\n", FENISH_LINE);
261224
}
262225
}
263226
}
@@ -356,3 +319,64 @@ fn rustc_exists() -> bool {
356319
.map(|status| status.success())
357320
.unwrap_or(false)
358321
}
322+
323+
const DEFAULT_OUT: &str = r#"Thanks for installing Rustlings!
324+
325+
Is this your first time? Don't worry, Rustlings was made for beginners! We are
326+
going to teach you a lot of things about Rust, but before we can get
327+
started, here's a couple of notes about how Rustlings operates:
328+
329+
1. The central concept behind Rustlings is that you solve exercises. These
330+
exercises usually have some sort of syntax error in them, which will cause
331+
them to fail compilation or testing. Sometimes there's a logic error instead
332+
of a syntax error. No matter what error, it's your job to find it and fix it!
333+
You'll know when you fixed it because then, the exercise will compile and
334+
Rustlings will be able to move on to the next exercise.
335+
2. If you run Rustlings in watch mode (which we recommend), it'll automatically
336+
start with the first exercise. Don't get confused by an error message popping
337+
up as soon as you run Rustlings! This is part of the exercise that you're
338+
supposed to solve, so open the exercise file in an editor and start your
339+
detective work!
340+
3. If you're stuck on an exercise, there is a helpful hint you can view by typing
341+
'hint' (in watch mode), or running `rustlings hint exercise_name`.
342+
4. If an exercise doesn't make sense to you, feel free to open an issue on GitHub!
343+
(https://github.com/rust-lang/rustlings/issues/new). We look at every issue,
344+
and sometimes, other learners do too so you can help each other out!
345+
346+
Got all that? Great! To get started, run `rustlings watch` in order to get the first
347+
exercise. Make sure to have your editor open!"#;
348+
349+
const FENISH_LINE: &str = r#"+----------------------------------------------------+
350+
| You made it to the Fe-nish line! |
351+
+-------------------------- ------------------------+
352+
\\/
353+
▒▒ ▒▒▒▒▒▒▒▒ ▒▒▒▒▒▒▒▒ ▒▒
354+
▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
355+
▒▒▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒▒▒
356+
░░▒▒▒▒░░▒▒ ▒▒ ▒▒ ▒▒ ▒▒░░▒▒▒▒
357+
▓▓▓▓▓▓▓▓ ▓▓ ▓▓██ ▓▓ ▓▓██ ▓▓ ▓▓▓▓▓▓▓▓
358+
▒▒▒▒ ▒▒ ████ ▒▒ ████ ▒▒░░ ▒▒▒▒
359+
▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒▒▒▒▒ ▒▒
360+
▒▒▒▒▒▒▒▒▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒▓▓▒▒▓▓▒▒▒▒▒▒▒▒
361+
▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
362+
▒▒▒▒▒▒▒▒▒▒██▒▒▒▒▒▒██▒▒▒▒▒▒▒▒▒▒
363+
▒▒ ▒▒▒▒▒▒▒▒▒▒██████▒▒▒▒▒▒▒▒▒▒ ▒▒
364+
▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒
365+
▒▒ ▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒ ▒▒ ▒▒
366+
▒▒ ▒▒ ▒▒ ▒▒ ▒▒ ▒▒
367+
▒▒ ▒▒ ▒▒ ▒▒
368+
369+
We hope you enjoyed learning about the various aspects of Rust!
370+
If you noticed any issues, please don't hesitate to report them to our repo.
371+
You can also contribute your own exercises to help the greater community!
372+
373+
Before reporting an issue or contributing, please read our guidelines:
374+
https://github.com/rust-lang/rustlings/blob/main/CONTRIBUTING.md"#;
375+
376+
const WELCOME: &str = r#" welcome to...
377+
_ _ _
378+
_ __ _ _ ___| |_| (_)_ __ __ _ ___
379+
| '__| | | / __| __| | | '_ \ / _` / __|
380+
| | | |_| \__ \ |_| | | | | | (_| \__ \
381+
|_| \__,_|___/\__|_|_|_| |_|\__, |___/
382+
|___/"#;

0 commit comments

Comments
 (0)