From bb49ecc929d7e0d8f0248b4d185dd6ca9a6d10ee Mon Sep 17 00:00:00 2001 From: Pranav Gaddamadugu Date: Fri, 29 Sep 2023 10:08:11 -0400 Subject: [PATCH] Update CLI --- leo/cli/commands/build.rs | 23 ++--------------------- leo/cli/commands/execute.rs | 12 ++---------- leo/cli/commands/mod.rs | 4 +--- leo/cli/commands/run.rs | 12 ++---------- 4 files changed, 7 insertions(+), 44 deletions(-) diff --git a/leo/cli/commands/build.rs b/leo/cli/commands/build.rs index e00ce5b74d..2966249d29 100644 --- a/leo/cli/commands/build.rs +++ b/leo/cli/commands/build.rs @@ -49,7 +49,6 @@ impl From for CompilerOptions { type_checked_symbol_table: options.enable_type_checked_symbol_table_snapshot, unrolled_symbol_table: options.enable_unrolled_symbol_table_snapshot, ast_spans_enabled: options.enable_ast_spans, - initial_input_ast: options.enable_initial_input_ast_snapshot, initial_ast: options.enable_initial_ast_snapshot, unrolled_ast: options.enable_unrolled_ast_snapshot, ssa_ast: options.enable_ssa_ast_snapshot, @@ -60,7 +59,6 @@ impl From for CompilerOptions { }, }; if options.enable_all_ast_snapshots { - out_options.output.initial_input_ast = true; out_options.output.initial_ast = true; out_options.output.unrolled_ast = true; out_options.output.ssa_ast = true; @@ -83,7 +81,7 @@ pub struct Build { impl Command for Build { type Input = (); - type Output = (Option, IndexMap); + type Output = (); fn log_span(&self) -> Span { tracing::span!(tracing::Level::INFO, "Leo") @@ -159,23 +157,6 @@ impl Command for Build { retriever.process_local(dependency)?; } - // Load the input file at `package_name.in` - let input_file_path = InputFile::new(&manifest.program_id().name().to_string()).setup_file_path(&package_path); - - // Parse the input file. - let input_ast = if input_file_path.exists() { - // Load the input file into the source map. - let input_sf = with_session_globals(|s| s.source_map.load_file(&input_file_path)) - .map_err(|e| CompilerError::file_read_error(&input_file_path, e))?; - - // TODO: This is a hack to notify the user that something is wrong with the input file. Redesign. - leo_parser::parse_input(&handler, &node_builder, &input_sf.src, input_sf.start_pos) - .map_err(|_e| println!("Warning: Failed to parse input file")) - .ok() - } else { - None - }; - // `Package::open` checks that the build directory and that `main.aleo` and all imported files are well-formed. Package::::open(&build_directory).map_err(CliError::failed_to_execute_build)?; @@ -197,7 +178,7 @@ impl Command for Build { // // Log the result of the build // tracing::info!("{}", result); - Ok((input_ast, structs)) + Ok(()) } } diff --git a/leo/cli/commands/execute.rs b/leo/cli/commands/execute.rs index 2df5b01510..9870af8a70 100644 --- a/leo/cli/commands/execute.rs +++ b/leo/cli/commands/execute.rs @@ -51,16 +51,8 @@ impl Command for Execute { (Build { options: self.compiler_options.clone() }).execute(context) } - fn apply(self, context: Context, input: Self::Input) -> Result { - // If input values are provided, then run the program with those inputs. - // Otherwise, use the input file. - let mut inputs = match self.inputs.is_empty() { - true => match input { - (Some(input_ast), circuits) => input_ast.program_inputs(&self.name, circuits), - _ => Vec::new(), - }, - false => self.inputs, - }; + fn apply(self, context: Context, _: Self::Input) -> Result { + let mut inputs = self.inputs; // Compose the `execute` command. let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name]; diff --git a/leo/cli/commands/mod.rs b/leo/cli/commands/mod.rs index a06cf64560..fc606785b8 100644 --- a/leo/cli/commands/mod.rs +++ b/leo/cli/commands/mod.rs @@ -49,7 +49,7 @@ pub use update::Update; use super::*; use crate::cli::helpers::context::*; -use leo_errors::{emitter::Handler, CliError, CompilerError, PackageError, Result}; +use leo_errors::{emitter::Handler, CliError, PackageError, Result}; use leo_package::{build::*, outputs::OutputsDirectory, package::*}; use clap::Parser; @@ -138,8 +138,6 @@ pub struct BuildOptions { pub enable_dce: bool, #[clap(long, help = "Writes all AST snapshots for the different compiler phases.")] pub enable_all_ast_snapshots: bool, - #[clap(long, help = "Writes Input AST snapshot of the initial parse.")] - pub enable_initial_input_ast_snapshot: bool, #[clap(long, help = "Writes AST snapshot of the initial parse.")] pub enable_initial_ast_snapshot: bool, #[clap(long, help = "Writes AST snapshot of the unrolled AST.")] diff --git a/leo/cli/commands/run.rs b/leo/cli/commands/run.rs index ab8d243625..cebecaf292 100644 --- a/leo/cli/commands/run.rs +++ b/leo/cli/commands/run.rs @@ -43,16 +43,8 @@ impl Command for Run { (Build { options: self.compiler_options.clone() }).execute(context) } - fn apply(self, context: Context, input: Self::Input) -> Result { - // If input values are provided, then run the program with those inputs. - // Otherwise, use the input file. - let mut inputs = match self.inputs.is_empty() { - true => match input { - (Some(input_ast), circuits) => input_ast.program_inputs(&self.name, circuits), - _ => Vec::new(), - }, - false => self.inputs, - }; + fn apply(self, context: Context, _: Self::Input) -> Result { + let mut inputs = self.inputs; // Compose the `run` command. let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name];