mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-11-27 12:17:35 +03:00
Update CLI
This commit is contained in:
parent
61eede48d7
commit
bb49ecc929
@ -49,7 +49,6 @@ impl From<BuildOptions> 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<BuildOptions> 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<InputAst>, IndexMap<Symbol, Struct>);
|
||||
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::<CurrentNetwork>::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(())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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<Self::Output> {
|
||||
// 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<Self::Output> {
|
||||
let mut inputs = self.inputs;
|
||||
|
||||
// Compose the `execute` command.
|
||||
let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name];
|
||||
|
@ -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.")]
|
||||
|
@ -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<Self::Output> {
|
||||
// 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<Self::Output> {
|
||||
let mut inputs = self.inputs;
|
||||
|
||||
// Compose the `run` command.
|
||||
let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name];
|
||||
|
Loading…
Reference in New Issue
Block a user