Skip to content

Commit

Permalink
fix(rust): improve ockam relay list display when local state is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
k1nho committed Sep 30, 2023
1 parent 6c9b1d8 commit bbb81e6
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions implementations/rust/ockam/ockam_command/src/relay/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,25 @@ async fn run_impl(
let to = get_node_name(&opts.state, &cmd.to);
let node_name = extract_address_value(&to)?;

if !opts.state.nodes.get(&node_name)?.is_running() {
return Err(miette!("The node '{}' is not running", node_name));
match opts.state.nodes.get(&node_name) {
Ok(node_state) => {
if !node_state.is_running() {
return Err(miette!("The node '{}' is not running", node_name));
}
}
Err(e) => {
if node_name == "default" {
let v: Vec<ForwarderInfo> = vec![];
let list = opts.terminal.build_list(
&v,
"Relays",
"Local state is empty, there are no relays.",
)?;
opts.terminal.stdout().plain(list).write_line()?;
return Ok(());
}
return Err(miette!("{}", e.to_string()));
}
}

let mut rpc = Rpc::background(&ctx, &opts, &node_name).await?;
Expand Down

0 comments on commit bbb81e6

Please sign in to comment.