Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More crutest and dsc updates to support Volume layer activities. #1472

Merged
merged 4 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 15 additions & 9 deletions crutest/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ pub struct CliAction {
#[allow(clippy::derive_partial_eq_without_eq)]
#[derive(Debug, Parser, PartialEq)]
pub enum DscCommand {
/// Connect to the default DSC server (http://127.0.0.1:9998)
Connect,
/// IP:Port for a dsc server
/// #[clap(long, global = true, default_value = "127.0.0.1:9998", action)]
Connect { server: SocketAddr },
/// Disable random stopping of downstairs
DisableRandomStop,
/// Disable auto restart on the given downstairs client ID
Expand Down Expand Up @@ -380,7 +381,7 @@ async fn handle_dsc(
) {
if let Some(dsc_client) = dsc_client {
match dsc_cmd {
DscCommand::Connect => {
DscCommand::Connect { .. } => {
println!("Already connected");
}
DscCommand::DisableRandomStop => {
Expand Down Expand Up @@ -444,13 +445,18 @@ async fn handle_dsc(
println!("Got res: {:?}", res);
}
}
} else if dsc_cmd == DscCommand::Connect {
let url = "http://127.0.0.1:9998".to_string();
println!("Connect to {:?}", url);
let rs = Client::new(&url);
*dsc_client = Some(rs);
} else {
println!("dsc: Need to be connected first");
match dsc_cmd {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you write this as

} else if let DscCommand::Connect { server } = dsc_cmd {

instead of the nested match?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's much better. Done in 11fb248

DscCommand::Connect { server } => {
let url = format!("http://{}", server).to_string();
println!("Connecting to {:?}", url);
let rs = Client::new(&url);
*dsc_client = Some(rs);
}
_ => {
println!("dsc: Need to be connected first");
}
}
}
}
/*
Expand Down
Loading