mirror of
https://github.com/notohh/rustlings.git
synced 2024-11-21 13:32:23 -05:00
Fix running dev commands
This commit is contained in:
parent
25e7696565
commit
df448c069c
2 changed files with 15 additions and 12 deletions
|
@ -59,6 +59,8 @@ pub fn init(exercise_infos: &[ExerciseInfo]) -> Result<()> {
|
|||
fs::write(".vscode/extensions.json", VS_CODE_EXTENSIONS_JSON)
|
||||
.context("Failed to create the file `rustlings/.vscode/extensions.json`")?;
|
||||
|
||||
println!("{POST_INIT_MSG}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -87,3 +89,8 @@ const RUSTLINGS_DIR_ALREADY_EXISTS_ERR: &str =
|
|||
You probably already initialized Rustlings.
|
||||
Run `cd rustlings`
|
||||
Then run `rustlings` again";
|
||||
|
||||
const POST_INIT_MSG: &str = "Done initialization!
|
||||
|
||||
Run `cd rustlings` to go into the generated directory.
|
||||
Then run `rustlings` to get started.";
|
||||
|
|
20
src/main.rs
20
src/main.rs
|
@ -72,10 +72,12 @@ fn main() -> Result<()> {
|
|||
bail!(FORMAT_VERSION_HIGHER_ERR);
|
||||
}
|
||||
|
||||
if matches!(args.command, Some(Subcommands::Init)) {
|
||||
init::init(&info_file.exercises).context("Initialization failed")?;
|
||||
println!("{POST_INIT_MSG}");
|
||||
return Ok(());
|
||||
match args.command {
|
||||
Some(Subcommands::Init) => {
|
||||
return init::init(&info_file.exercises).context("Initialization failed");
|
||||
}
|
||||
Some(Subcommands::Dev(dev_command)) => return dev_command.run(),
|
||||
_ => (),
|
||||
}
|
||||
|
||||
if !Path::new("exercises").is_dir() {
|
||||
|
@ -133,8 +135,6 @@ fn main() -> Result<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
// `Init` is handled above.
|
||||
Some(Subcommands::Init) => (),
|
||||
Some(Subcommands::Run { name }) => {
|
||||
if let Some(name) = name {
|
||||
app_state.set_current_exercise_by_name(&name)?;
|
||||
|
@ -152,7 +152,8 @@ fn main() -> Result<()> {
|
|||
app_state.set_current_exercise_by_name(&name)?;
|
||||
println!("{}", app_state.current_exercise().hint);
|
||||
}
|
||||
Some(Subcommands::Dev(dev_command)) => dev_command.run()?,
|
||||
// Handled in an earlier match.
|
||||
Some(Subcommands::Init | Subcommands::Dev(_)) => (),
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -167,11 +168,6 @@ const FORMAT_VERSION_HIGHER_ERR: &str =
|
|||
It is possible that you have an outdated version of Rustlings.
|
||||
Try to install the latest Rustlings version first.";
|
||||
|
||||
const POST_INIT_MSG: &str = "Done initialization!
|
||||
|
||||
Run `cd rustlings` to go into the generated directory.
|
||||
Then run `rustlings` to get started.";
|
||||
|
||||
const PRE_INIT_MSG: &str = r"
|
||||
Welcome to...
|
||||
_ _ _
|
||||
|
|
Loading…
Reference in a new issue