11use  crate :: rpc_call:: make_rpc_call; 
2- use  anyhow:: Context ; 
2+ use  anyhow:: { bail ,   Context } ; 
33use  base64:: { engine:: general_purpose,  Engine  as  _} ; 
44use  clap:: Subcommand ; 
55use  jsonrpsee:: core:: params:: ObjectParams ; 
@@ -35,7 +35,7 @@ pub enum ScenarioCommand {
3535async  fn  handle_available ( params :  ObjectParams )  -> anyhow:: Result < ( ) >  { 
3636    let  data = make_rpc_call ( "scenarios_available" ,  params) 
3737        . await 
38-         . context ( "Failed  to fetch available scenarios" ) ?; 
38+         . context ( "Making RPC  to fetch available scenarios" ) ?; 
3939    if  let  serde_json:: Value :: Array ( scenarios)  = data { 
4040        let  mut  table = Table :: new ( ) ; 
4141        table. add_row ( row ! [ "Scenario" ,  "Description" ] ) ; 
@@ -50,7 +50,7 @@ async fn handle_available(params: ObjectParams) -> anyhow::Result<()> {
5050        } 
5151        table. printstd ( ) ; 
5252    }  else  { 
53-         println ! ( "Unexpected response format." ) ; 
53+         bail ! ( "Unexpected response format." ) ; 
5454    } 
5555    Ok ( ( ) ) 
5656} 
@@ -68,7 +68,7 @@ async fn handle_run(
6868        . context ( "Add additional_args to params" ) ?; 
6969    let  data = make_rpc_call ( "scenarios_run" ,  params) 
7070        . await 
71-         . context ( "Failed  to run scenario" ) ?; 
71+         . context ( "Making RPC call  to run scenario with remote file " ) ?; 
7272    println ! ( "{:?}" ,  data) ; 
7373    Ok ( ( ) ) 
7474} 
@@ -82,21 +82,21 @@ async fn handle_run_file(
8282    let  scenario_base64 = general_purpose:: STANDARD . encode ( file_contents) ; 
8383    params
8484        . insert ( "scenario_base64" ,  scenario_base64) 
85-         . context ( "Add  scenario to params" ) ?; 
85+         . context ( "Adding  scenario to params" ) ?; 
8686    params
8787        . insert ( "additional_args" ,  additional_args) 
88-         . context ( "Add  additional_args to params" ) ?; 
88+         . context ( "Adding  additional_args to params" ) ?; 
8989    let  data = make_rpc_call ( "scenarios_run_file" ,  params) 
9090        . await 
91-         . context ( "Failed  to run scenario" ) ?; 
91+         . context ( "Making RPC call  to run scenario with local file " ) ?; 
9292    println ! ( "{:?}" ,  data) ; 
9393    Ok ( ( ) ) 
9494} 
9595
9696async  fn  handle_active ( params :  ObjectParams )  -> anyhow:: Result < ( ) >  { 
9797    let  data = make_rpc_call ( "scenarios_list_running" ,  params) 
9898        . await 
99-         . context ( "Failed  to list running scenarios" ) ?; 
99+         . context ( "Making RPC call  to list running scenarios" ) ?; 
100100    if  let  serde_json:: Value :: Array ( scenarios)  = data { 
101101        let  mut  table = Table :: new ( ) ; 
102102        table. add_row ( row ! [ "PID" ,  "Command" ,  "Network" ,  "Active" ] ) ; 
@@ -123,7 +123,7 @@ async fn handle_active(params: ObjectParams) -> anyhow::Result<()> {
123123        } 
124124        table. printstd ( ) ; 
125125    }  else  { 
126-         println ! ( "Unexpected response format." ) ; 
126+         bail ! ( "Unexpected response format." ) ; 
127127    } 
128128    Ok ( ( ) ) 
129129} 
@@ -132,11 +132,11 @@ async fn handle_stop(mut params: ObjectParams, pid: &u64) -> anyhow::Result<()>
132132    params. insert ( "pid" ,  pid) . context ( "Add pid to params" ) ?; 
133133    let  data = make_rpc_call ( "scenarios_stop" ,  params) 
134134        . await 
135-         . context ( "Failed  to stop running scenario" ) ?; 
135+         . context ( "Making RPC call  to stop running scenario" ) ?; 
136136    if  let  serde_json:: Value :: String ( message)  = data { 
137137        println ! ( "{}" ,  message) ; 
138138    }  else  { 
139-         println ! ( "Unexpected response format." ) ; 
139+         bail ! ( "Unexpected response format." ) ; 
140140    } 
141141    Ok ( ( ) ) 
142142} 
0 commit comments