Skip to content

Commit

Permalink
Reset command (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dentosal authored Jun 13, 2022
1 parent c6382be commit 618b0c2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
"path/to/tx.json -- start a new transaction",
["n", "tx", "new_tx", "start_tx"]
);
command!(
cmd_reset,
"-- reset, removing breakpoints and other state",
["reset"]
);
command!(
cmd_continue,
"-- run until next breakpoint or termination",
Expand Down Expand Up @@ -100,6 +105,17 @@ async fn cmd_start_tx(state: &mut State, mut args: Vec<String>) -> Result<(), Bo
Ok(())
}

async fn cmd_reset(state: &mut State, mut args: Vec<String>) -> Result<(), Box<dyn Error>> {
args.remove(0);
if !args.is_empty() {
return Err(Box::new(ArgError::TooMany));
}

let _ = state.client.reset(&state.session_id).await?;

Ok(())
}

async fn cmd_continue(state: &mut State, mut args: Vec<String>) -> Result<(), Box<dyn Error>> {
args.remove(0);
if !args.is_empty() {
Expand Down
3 changes: 3 additions & 0 deletions tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ fn test_cli() {
cmd.exp_regex(r">> ").unwrap();
cmd.send_line("continue").unwrap();
cmd.exp_regex(r"breakpoint: None").unwrap();
cmd.send_line("reset").unwrap();
cmd.send_line("start_tx examples/example_tx.json").unwrap();
cmd.exp_regex(r"breakpoint: None").unwrap();
cmd.send_line(r"exit").unwrap();

fuel_core.kill().expect("Couldn't kill fuel-core");
Expand Down

0 comments on commit 618b0c2

Please sign in to comment.