From 1eac00e89ae9e0ed6969f5036e9c8c43e4435e86 Mon Sep 17 00:00:00 2001 From: mo8it Date: Thu, 18 Apr 2024 11:28:28 +0200 Subject: [PATCH] Disable init command during development --- src/dev.rs | 12 ++++++++++-- src/main.rs | 4 ++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/dev.rs b/src/dev.rs index feca99e5..1430f11e 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -1,6 +1,8 @@ -use anyhow::{Context, Result}; +use anyhow::{bail, Context, Result}; use clap::Subcommand; +use crate::DEVELOPING_OFFICIAL_RUSTLINGS; + mod check; mod init; mod update; @@ -15,7 +17,13 @@ pub enum DevCommands { impl DevCommands { pub fn run(self) -> Result<()> { match self { - DevCommands::Init => init::init().context(INIT_ERR), + DevCommands::Init => { + if DEVELOPING_OFFICIAL_RUSTLINGS { + bail!("Disabled while developing the official Rustlings"); + } + + init::init().context(INIT_ERR) + } DevCommands::Check => check::check(), DevCommands::Update => update::update(), } diff --git a/src/main.rs b/src/main.rs index 3f3fbc1d..d40f978c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,6 +79,10 @@ fn main() -> Result<()> { match args.command { Some(Subcommands::Init) => { + if DEVELOPING_OFFICIAL_RUSTLINGS { + bail!("Disabled while developing the official Rustlings"); + } + return init::init().context("Initialization failed"); } Some(Subcommands::Dev(dev_command)) => return dev_command.run(),