Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ exclude = [
"tests/test_exercises",
"dev",
]
members = ["src"]

[workspace.package]
version = "6.5.0"
Expand Down
224 changes: 223 additions & 1 deletion dev-Cargo.toml
17 changes: 17 additions & 0 deletions src/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[package]
name = "src"
version.workspace = true
authors.workspace = true
repository.workspace = true
license.workspace = true
edition.workspace = true
rust-version.workspace = true

[dependencies]

[[bin]]
name = "src"
path = "main.rs"

[lints]
workspace = true
21 changes: 16 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,32 @@ enum Subcommands {
#[command(subcommand)]
Dev(DevCommands),
}

// Main function
fn main() -> Result<ExitCode> {
let args = Args::parse();

// Parse command-line arguments using the Clap derive macro
let args = Args::parse();
// Safety check: Prevent running with the legacy repository structure.
// This triggers only in non-debug (release) builds if the old repo path is detected.
if cfg!(not(debug_assertions)) && Path::new("dev/rustlings-repo.txt").exists() {
bail!("{OLD_METHOD_ERR}");
}

// Labeled block to handle high-priority subcommands that should terminate
// execution early upon completion.
'priority_cmd: {
match args.command {
// Handle environment initialization
Some(Subcommands::Init) => init::init().context("Initialization failed")?,

// Handle internal developer-specific commands
Some(Subcommands::Dev(dev_command)) => dev_command.run()?,

// If the command is not a priority, break out of the labeled block
// to proceed with the normal execution flow (e.g., running exercises)

_ => break 'priority_cmd,
}


// Successfully executed a priority command; exit the program
return Ok(ExitCode::SUCCESS);
}

Expand Down
Loading