mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-22 17:51:39 +03:00
fix leo execute command line argument parsing (#2530)
* fix leo execute command line argument parsing * add leo-examples integration test to ci and include leo execute commands * give leo-example.sh execute permission
This commit is contained in:
parent
85d9a28ebb
commit
700e31f113
@ -126,6 +126,19 @@ jobs:
|
||||
export LEO=/home/circleci/project/project/bin/leo
|
||||
./project/.circleci/leo-clean.sh
|
||||
|
||||
leo-example:
|
||||
docker:
|
||||
- image: cimg/rust:1.71
|
||||
resource_class: xlarge
|
||||
steps:
|
||||
- attach_workspace:
|
||||
at: /home/circleci/project/
|
||||
- run:
|
||||
name: leo example
|
||||
command: |
|
||||
export LEO=/home/circleci/project/project/bin/leo
|
||||
./project/.circleci/leo-example.sh
|
||||
|
||||
test-examples:
|
||||
docker:
|
||||
- image: cimg/rust:1.71
|
||||
@ -153,6 +166,9 @@ workflows:
|
||||
- leo-clean:
|
||||
requires:
|
||||
- leo-executable
|
||||
- leo-example:
|
||||
requires:
|
||||
- leo-executable
|
||||
- test-examples:
|
||||
requires:
|
||||
- leo-executable
|
||||
|
11
.circleci/leo-example.sh
Normal file → Executable file
11
.circleci/leo-example.sh
Normal file → Executable file
@ -6,6 +6,9 @@
|
||||
|
||||
# Run the play function.
|
||||
$LEO run play || exit
|
||||
|
||||
# Execute the play function.
|
||||
$LEO execute play || exit
|
||||
)
|
||||
|
||||
(
|
||||
@ -17,8 +20,11 @@
|
||||
# Create a new game.
|
||||
$LEO run new || exit
|
||||
|
||||
# Create a make a move.
|
||||
# Run the make_move function.
|
||||
$LEO run make_move || exit
|
||||
|
||||
# Execute the make_move function.
|
||||
$LEO execute make_move || exit
|
||||
)
|
||||
|
||||
(
|
||||
@ -29,4 +35,7 @@
|
||||
|
||||
# Run the mint_public function.
|
||||
$LEO run mint_public || exit
|
||||
|
||||
# Execute the mint_public function.
|
||||
$LEO execute mint_public || exit
|
||||
)
|
||||
|
@ -27,8 +27,13 @@ pub struct Execute {
|
||||
#[clap(name = "INPUTS", help = "The inputs to the program. If none are provided, the input file is used.")]
|
||||
inputs: Vec<String>,
|
||||
|
||||
#[clap(name = "ENDPOINT", help = "The specified network endpoint")]
|
||||
endpoint: Option<String>,
|
||||
#[clap(
|
||||
name = "ENDPOINT",
|
||||
help = "The specified network endpoint.",
|
||||
default_value = "https://api.explorer.aleo.org/v1",
|
||||
long
|
||||
)]
|
||||
endpoint: String,
|
||||
|
||||
#[clap(flatten)]
|
||||
pub(crate) compiler_options: BuildOptions,
|
||||
@ -59,8 +64,19 @@ impl Command for Execute {
|
||||
|
||||
// Compose the `execute` command.
|
||||
let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name];
|
||||
|
||||
// Add the program inputs to the arguments.
|
||||
arguments.append(&mut inputs);
|
||||
|
||||
// Add the compiler options to the arguments.
|
||||
if self.compiler_options.offline {
|
||||
arguments.push(String::from("--offline"));
|
||||
}
|
||||
|
||||
// Add the endpoint to the arguments.
|
||||
arguments.push(String::from("--endpoint"));
|
||||
arguments.push(self.endpoint);
|
||||
|
||||
// Open the Leo build/ directory
|
||||
let path = context.dir()?;
|
||||
let build_directory = BuildDirectory::open(&path)?;
|
||||
@ -69,19 +85,10 @@ impl Command for Execute {
|
||||
std::env::set_current_dir(&build_directory)
|
||||
.map_err(|err| PackageError::failed_to_set_cwd(build_directory.display(), err))?;
|
||||
|
||||
// Call the `execute` command.
|
||||
if self.compiler_options.offline {
|
||||
arguments.push(String::from("--offline"));
|
||||
}
|
||||
|
||||
if self.endpoint.is_some() {
|
||||
arguments.push(String::from("--endpoint"));
|
||||
arguments.push(self.endpoint.unwrap());
|
||||
}
|
||||
|
||||
// Unset the Leo panic hook
|
||||
let _ = std::panic::take_hook();
|
||||
|
||||
// Call the `execute` command.
|
||||
println!();
|
||||
let command = SnarkVMExecute::try_parse_from(&arguments).map_err(CliError::failed_to_parse_execute)?;
|
||||
let res = command.parse().map_err(CliError::failed_to_execute_execute)?;
|
||||
|
@ -56,6 +56,8 @@ impl Command for Run {
|
||||
|
||||
// Compose the `run` command.
|
||||
let mut arguments = vec![SNARKVM_COMMAND.to_string(), self.name];
|
||||
|
||||
// Add the program inputs to the arguments.
|
||||
arguments.append(&mut inputs);
|
||||
|
||||
// Open the Leo build/ directory
|
||||
|
Loading…
Reference in New Issue
Block a user