mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-09-19 01:37:34 +03:00
impl leo run foo to target program names
This commit is contained in:
parent
0fa337bbef
commit
6aec344ed3
@ -41,9 +41,10 @@ pub struct InputAst {
|
||||
|
||||
impl InputAst {
|
||||
/// Returns all values of the input AST for execution with `leo run`.
|
||||
pub fn values(&self) -> Vec<String> {
|
||||
pub fn program_inputs(&self, program_name: &str) -> Vec<String> {
|
||||
self.sections
|
||||
.iter()
|
||||
.filter(|section| §ion.name() == program_name)
|
||||
.flat_map(|section| {
|
||||
section
|
||||
.definitions
|
||||
|
@ -24,3 +24,9 @@ pub struct Section {
|
||||
pub definitions: Vec<Definition>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Section {
|
||||
pub fn name(&self) -> String {
|
||||
self.name.to_string()
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +0,0 @@
|
||||
circuit Other {
|
||||
a: u64,
|
||||
}
|
@ -3,3 +3,5 @@
|
||||
public a: u32 = 1u32;
|
||||
b: u32 = 2u32; // Input variable `b` is private by default.
|
||||
|
||||
[foo]
|
||||
x: u64 = 5u64;
|
@ -1,8 +1,8 @@
|
||||
import other.leo;
|
||||
|
||||
// The 'helloworld' main function.
|
||||
function main(public a: u32, b: u32) -> u32 {
|
||||
let o: Other = Other { a: 1u64 };
|
||||
|
||||
return a + b;
|
||||
}
|
||||
|
||||
function foo(x: u64) -> u64 {
|
||||
return x - x;
|
||||
}
|
@ -31,6 +31,9 @@ use tracing::span::Span;
|
||||
/// Build, Prove and Run Leo program with inputs
|
||||
#[derive(StructOpt, Debug)]
|
||||
pub struct Run {
|
||||
#[structopt(name = "NAME", help = "The name of the program to run.", default_value = "main")]
|
||||
name: String,
|
||||
|
||||
#[structopt(long = "skip-key-check", help = "Skip key verification on Setup stage")]
|
||||
pub(crate) skip_key_check: bool,
|
||||
|
||||
@ -54,17 +57,15 @@ impl Command for Run {
|
||||
}
|
||||
|
||||
fn apply(self, context: Context, input: Self::Input) -> Result<Self::Output> {
|
||||
// Compose the `aleo run` command.
|
||||
let mut arguments = vec![ALEO_CLI_COMMAND.to_string(), "main".to_string()];
|
||||
|
||||
// Get the input values.
|
||||
let mut values = match input {
|
||||
Some(input_ast) => input_ast.values(),
|
||||
let mut inputs = match input {
|
||||
Some(input_ast) => input_ast.program_inputs(&self.name),
|
||||
None => Vec::new(),
|
||||
};
|
||||
arguments.append(&mut values);
|
||||
|
||||
tracing::info!("Starting...");
|
||||
// Compose the `aleo run` command.
|
||||
let mut arguments = vec![ALEO_CLI_COMMAND.to_string(), self.name];
|
||||
arguments.append(&mut inputs);
|
||||
|
||||
// Open the Leo build/ directory
|
||||
let path = context.dir()?;
|
||||
|
Loading…
Reference in New Issue
Block a user