Skip to content

Commit

Permalink
Support dumping return value
Browse files Browse the repository at this point in the history
  • Loading branch information
udoprog committed Jul 8, 2024
1 parent b0afc1e commit 38de932
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/rune/src/cli/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ pub(super) struct Flags {
/// Perform a default dump.
#[arg(short, long)]
dump: bool,
/// Dump return value.
#[arg(long)]
dump_return: bool,
/// Dump everything that is available, this is very verbose.
#[arg(long)]
dump_all: bool,
Expand Down Expand Up @@ -69,6 +72,7 @@ impl CommandBase for Flags {
if self.dump || self.dump_all {
self.dump_unit = true;
self.dump_stack = true;
self.dump_return = true;
}

if self.dump_all {
Expand Down Expand Up @@ -231,15 +235,15 @@ pub(super) async fn run(

let errored = match result {
VmResult::Ok(result) => {
if c.verbose || args.time {
if c.verbose || args.time || args.dump_return {
let duration = Instant::now().saturating_duration_since(last);
writeln!(io.stderr, "== {:?} ({:?})", result, duration)?;
}

None
}
VmResult::Err(error) => {
if c.verbose || args.time {
if c.verbose || args.time || args.dump_return {
let duration = Instant::now().saturating_duration_since(last);
writeln!(io.stderr, "== ! ({}) ({:?})", error, duration)?;
}
Expand Down

0 comments on commit 38de932

Please sign in to comment.