mirror of
https://github.com/rust-lang/rustlings.git
synced 2025-07-13 01:20:42 +02:00
Split lines after newline
This commit is contained in:
@ -134,7 +134,14 @@ mod tests {
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
updated_cargo_toml(&exercise_infos, "abc\nbin = [xxx]\n123", b"../").unwrap(),
|
||||
updated_cargo_toml(
|
||||
&exercise_infos,
|
||||
"abc\n\
|
||||
bin = [xxx]\n\
|
||||
123",
|
||||
b"../"
|
||||
)
|
||||
.unwrap(),
|
||||
br#"abc
|
||||
bin = [
|
||||
{ name = "1", path = "../exercises/1.rs" },
|
||||
|
@ -106,13 +106,15 @@ fn check_info_file_exercises(info_file: &InfoFile) -> Result<HashSet<PathBuf>> {
|
||||
|
||||
if !file_buf.contains("fn main()") {
|
||||
bail!(
|
||||
"The `main` function is missing in the file `{path}`.\nCreate at least an empty `main` function to avoid language server errors"
|
||||
"The `main` function is missing in the file `{path}`.\n\
|
||||
Create at least an empty `main` function to avoid language server errors"
|
||||
);
|
||||
}
|
||||
|
||||
if !file_buf.contains("// TODO") {
|
||||
bail!(
|
||||
"Didn't find any `// TODO` comment in the file `{path}`.\nYou need to have at least one such comment to guide the user."
|
||||
"Didn't find any `// TODO` comment in the file `{path}`.\n\
|
||||
You need to have at least one such comment to guide the user."
|
||||
);
|
||||
}
|
||||
|
||||
@ -227,7 +229,10 @@ fn check_exercises_unsolved(
|
||||
|
||||
match result {
|
||||
Ok(true) => {
|
||||
bail!("The exercise {exercise_name} is already solved.\n{SKIP_CHECK_UNSOLVED_HINT}",)
|
||||
bail!(
|
||||
"The exercise {exercise_name} is already solved.\n\
|
||||
{SKIP_CHECK_UNSOLVED_HINT}",
|
||||
)
|
||||
}
|
||||
Ok(false) => (),
|
||||
Err(e) => return Err(e),
|
||||
@ -242,10 +247,12 @@ fn check_exercises_unsolved(
|
||||
fn check_exercises(info_file: &'static InfoFile, cmd_runner: &'static CmdRunner) -> Result<()> {
|
||||
match info_file.format_version.cmp(&CURRENT_FORMAT_VERSION) {
|
||||
Ordering::Less => bail!(
|
||||
"`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\nPlease migrate to the latest format version"
|
||||
"`format_version` < {CURRENT_FORMAT_VERSION} (supported version)\n\
|
||||
Please migrate to the latest format version"
|
||||
),
|
||||
Ordering::Greater => bail!(
|
||||
"`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\nTry updating the Rustlings program"
|
||||
"`format_version` > {CURRENT_FORMAT_VERSION} (supported version)\n\
|
||||
Try updating the Rustlings program"
|
||||
),
|
||||
Ordering::Equal => (),
|
||||
}
|
||||
|
12
src/init.rs
12
src/init.rs
@ -58,11 +58,13 @@ pub fn init() -> Result<()> {
|
||||
&& !workspace_manifest_content.contains("workspace.")
|
||||
{
|
||||
bail!(
|
||||
"The current directory is already part of a Cargo project.\nPlease initialize Rustlings in a different directory"
|
||||
"The current directory is already part of a Cargo project.\n\
|
||||
Please initialize Rustlings in a different directory"
|
||||
);
|
||||
}
|
||||
|
||||
stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\nPress ENTER to continue ")?;
|
||||
stdout.write_all(b"This command will create the directory `rustlings/` as a member of this Cargo workspace.\n\
|
||||
Press ENTER to continue ")?;
|
||||
press_enter_prompt(&mut stdout)?;
|
||||
|
||||
// Make sure "rustlings" is added to `workspace.members` by making
|
||||
@ -78,7 +80,8 @@ pub fn init() -> Result<()> {
|
||||
.status()?;
|
||||
if !status.success() {
|
||||
bail!(
|
||||
"Failed to initialize a new Cargo workspace member.\nPlease initialize Rustlings in a different directory"
|
||||
"Failed to initialize a new Cargo workspace member.\n\
|
||||
Please initialize Rustlings in a different directory"
|
||||
);
|
||||
}
|
||||
|
||||
@ -87,7 +90,8 @@ pub fn init() -> Result<()> {
|
||||
.context("Failed to remove the temporary directory `rustlings/`")?;
|
||||
init_git = false;
|
||||
} else {
|
||||
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\nPress ENTER to continue ")?;
|
||||
stdout.write_all(b"This command will create the directory `rustlings/` which will contain the exercises.\n\
|
||||
Press ENTER to continue ")?;
|
||||
press_enter_prompt(&mut stdout)?;
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,11 @@ fn main() -> Result<ExitCode> {
|
||||
clear_terminal(&mut stdout)?;
|
||||
|
||||
let welcome_message = welcome_message.trim_ascii();
|
||||
write!(stdout, "{welcome_message}\n\nPress ENTER to continue ")?;
|
||||
write!(
|
||||
stdout,
|
||||
"{welcome_message}\n\n\
|
||||
Press ENTER to continue "
|
||||
)?;
|
||||
press_enter_prompt(&mut stdout)?;
|
||||
clear_terminal(&mut stdout)?;
|
||||
// Flush to be able to show errors occurring before printing a newline to stdout.
|
||||
|
Reference in New Issue
Block a user