Skip to content

Commit

Permalink
Examples: fix overwritten mode in config file (fix #700) (#702)
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch authored Jan 31, 2024
1 parent 0b6d65d commit 1de9d36
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ pub struct CommonArgs {
#[arg(short, long)]
/// A configuration file.
config: Option<String>,
#[arg(short, long, default_value = "peer")]
/// The Zenoh session mode.
mode: Wai,
#[arg(short, long)]
/// The Zenoh session mode [default: peer].
mode: Option<Wai>,
#[arg(short = 'e', long)]
/// Endpoints to connect to.
connect: Vec<String>,
Expand All @@ -48,10 +48,12 @@ impl From<&CommonArgs> for Config {
Some(path) => Config::from_file(path).unwrap(),
None => Config::default(),
};
println!("ARGS mode: {:?} ", value.mode);
match value.mode {
Wai::Peer => config.set_mode(Some(zenoh::scouting::WhatAmI::Peer)),
Wai::Client => config.set_mode(Some(zenoh::scouting::WhatAmI::Client)),
Wai::Router => config.set_mode(Some(zenoh::scouting::WhatAmI::Router)),
Some(Wai::Peer) => config.set_mode(Some(zenoh::scouting::WhatAmI::Peer)),
Some(Wai::Client) => config.set_mode(Some(zenoh::scouting::WhatAmI::Client)),
Some(Wai::Router) => config.set_mode(Some(zenoh::scouting::WhatAmI::Router)),
None => Ok(None),
}
.unwrap();
if !value.connect.is_empty() {
Expand Down

0 comments on commit 1de9d36

Please sign in to comment.