Files
mxaccessgw/clients/rust/crates/mxgw-cli/src/smoke.rs
T
Joseph Doherty 2a91e2b083
ci / nightly-windev (push) Has been skipped
ci / windows-x86 (push) Successful in 1m27s
ci / java (push) Successful in 2m3s
ci / portable (push) Failing after 4m10s
refactor(rust-cli): split mxgw-cli main.rs by command group (mxaccessgw#203)
Pure move: cli definition, per-group handlers (session, bulk, bench, events,
galaxy, smoke, batch) and shared output/parse/connect helpers now live in
their own modules. No behaviour or CLI surface change; --help of all 33
commands is byte-identical, clippy clean, tests unchanged.

Claude-Session: https://claude.ai/code/session_01GT67AEHd2Acv1YPwGfXEoV
2026-11-09 13:17:16 -05:00

58 lines
1.9 KiB
Rust

//! `smoke` command: open, register, add-item and close in one invocation.
use serde_json::json;
use zb_mom_ww_mxgateway_client::generated::mxaccess_gateway::v1::OpenSessionRequest;
use zb_mom_ww_mxgateway_client::Error;
use crate::cli::*;
use crate::connect::*;
/// Run the `smoke` command group.
pub(crate) async fn run(command: Command) -> Result<(), Error> {
match command {
Command::Smoke {
connection,
item,
client_name,
json,
} => {
let client = connect(connection).await?;
let session = client
.open_session(OpenSessionRequest {
client_session_name: client_name.clone(),
..OpenSessionRequest::default()
})
.await?;
let result = async {
let server_handle = session.register(&client_name).await?;
let item_handle = session.add_item(server_handle, &item).await?;
session.advise(server_handle, item_handle).await?;
Ok::<_, Error>((server_handle, item_handle))
}
.await;
let close_result = session.close().await;
let (server_handle, item_handle) = result?;
close_result?;
if json {
println!(
"{}",
json!({
"sessionId": session.id(),
"serverHandle": server_handle,
"itemHandle": item_handle,
"closed": true,
})
);
} else {
println!(
"session {} registered server {server_handle}, item {item_handle}, closed",
session.id()
);
}
}
_ => unreachable!("command routed to the wrong group"),
}
Ok(())
}