mirror of
https://github.com/fluencelabs/marine.git
synced 2024-12-12 06:45:32 +00:00
Add -nr flag to repl (#72)
This commit is contained in:
parent
80337a04d7
commit
6d4ef8200b
@ -128,11 +128,20 @@ impl REPL {
|
||||
println!("{}", result_msg);
|
||||
}
|
||||
|
||||
fn call_module<'args>(&mut self, mut args: impl Iterator<Item = &'args str>) {
|
||||
fn call_module<'args>(&mut self, args: impl Iterator<Item = &'args str>) {
|
||||
use itertools::Itertools;
|
||||
|
||||
let mut args = args.peekable();
|
||||
next_argument!(module_name, args, "Module name should be specified");
|
||||
next_argument!(func_name, args, "Function name should be specified");
|
||||
let show_result_arg = match args.peek() {
|
||||
Some(option) if *option == "-nr" => {
|
||||
args.next();
|
||||
false
|
||||
}
|
||||
Some(_) => true,
|
||||
None => true,
|
||||
};
|
||||
|
||||
let module_arg: String = args.join(" ");
|
||||
let module_arg: serde_json::Value = match serde_json::from_str(&module_arg) {
|
||||
@ -150,10 +159,14 @@ impl REPL {
|
||||
.app_service
|
||||
.call_module(module_name, func_name, module_arg, <_>::default())
|
||||
{
|
||||
Ok(result) => {
|
||||
Ok(result) if show_result_arg => {
|
||||
let elapsed_time = start.elapsed();
|
||||
format!("result: {:?}\n elapsed time: {:?}", result, elapsed_time)
|
||||
}
|
||||
Ok(_) => {
|
||||
let elapsed_time = start.elapsed();
|
||||
format!("call succeeded, elapsed time: {:?}", elapsed_time)
|
||||
}
|
||||
Err(e) => format!("call failed with: {}", e),
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user