From 8f1ffb6874d1462ebaa820ee6053bf3a0c85fcbe Mon Sep 17 00:00:00 2001 From: lambda-0x <0xlambda@protonmail.com> Date: Sun, 21 Jan 2024 16:55:19 +0530 Subject: [PATCH] rename plan to dry_run and revert name related changes --- crates/sozo/src/commands/migrate.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/crates/sozo/src/commands/migrate.rs b/crates/sozo/src/commands/migrate.rs index 1705032a22..b34f000da0 100644 --- a/crates/sozo/src/commands/migrate.rs +++ b/crates/sozo/src/commands/migrate.rs @@ -14,8 +14,7 @@ use crate::ops::migration; pub struct MigrateArgs { #[arg(short, long)] #[arg(help = "Perform a dry run and outputs the plan to be executed.")] - // TODO: i think dry_run would be more descriptive - pub plan: bool, + pub dry_run: bool, #[arg(long)] #[arg(help = "Name of the World.")] @@ -37,9 +36,16 @@ pub struct MigrateArgs { } impl MigrateArgs { - pub fn run(self, config: &Config) -> Result<()> { + pub fn run(mut self, config: &Config) -> Result<()> { let ws = scarb::ops::read_workspace(config.manifest_path(), config)?; + // If `name` was not specified use package name from `Scarb.toml` file if it exists + if self.name.is_none() { + if let Some(root_package) = ws.root_package() { + self.name = Some(root_package.id.name.to_string()); + } + } + let target_dir = ws.target_dir().path_existent().unwrap(); let target_dir = target_dir.join(ws.config().profile().as_str());