summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authormo8it <mo8it@proton.me>2024-04-17 15:55:50 +0200
committermo8it <mo8it@proton.me>2024-04-17 15:55:50 +0200
commit501b973c258a3c2e3a463d58c16402302184380f (patch)
treea03812f5d3f5a5ef9e171077fb6aa6571a3f31fb /src/main.rs
parent30636e7cf345757f95235744ff81376ae81c9aa2 (diff)
Add "dev update"
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs27
1 files changed, 19 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs
index 8b3f28f..ea5f7c9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,17 @@ mod watch;
use self::{app_state::AppState, dev::DevCommands, info_file::InfoFile, watch::WatchExit};
const CURRENT_FORMAT_VERSION: u8 = 1;
+const DEVELOPING_OFFIFICAL_RUSTLINGS: bool = {
+ #[allow(unused_assignments, unused_mut)]
+ let mut debug_profile = false;
+
+ #[cfg(debug_assertions)]
+ {
+ debug_profile = true;
+ }
+
+ debug_profile
+};
/// Rustlings is a collection of small exercises to get you used to writing and reading Rust code
#[derive(Parser)]
@@ -66,17 +77,11 @@ fn main() -> Result<()> {
which::which("cargo").context(CARGO_NOT_FOUND_ERR)?;
- let info_file = InfoFile::parse()?;
-
- if info_file.format_version > CURRENT_FORMAT_VERSION {
- bail!(FORMAT_VERSION_HIGHER_ERR);
- }
-
match args.command {
Some(Subcommands::Init) => {
- return init::init(&info_file.exercises).context("Initialization failed");
+ return init::init().context("Initialization failed");
}
- Some(Subcommands::Dev(dev_command)) => return dev_command.run(info_file),
+ Some(Subcommands::Dev(dev_command)) => return dev_command.run(),
_ => (),
}
@@ -85,6 +90,12 @@ fn main() -> Result<()> {
exit(1);
}
+ let info_file = InfoFile::parse()?;
+
+ if info_file.format_version > CURRENT_FORMAT_VERSION {
+ bail!(FORMAT_VERSION_HIGHER_ERR);
+ }
+
let (mut app_state, state_file_status) = AppState::new(
info_file.exercises,
info_file.final_message.unwrap_or_default(),