From 9d166ed45505f743b7f81d2f618d957374e09535 Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Wed, 31 Jan 2024 10:47:03 +0100 Subject: [PATCH 1/2] Examples: fix overwritten mode in config file (fix #700) --- examples/src/lib.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 255ac01917..3a8c73ad48 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -20,9 +20,9 @@ pub struct CommonArgs { #[arg(short, long)] /// A configuration file. config: Option, - #[arg(short, long, default_value = "peer")] - /// The Zenoh session mode. - mode: Wai, + #[arg(short, long)] + /// The Zenoh session mode [default: peer]. + mode: Option, #[arg(short = 'e', long)] /// Endpoints to connect to. connect: Vec, @@ -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() { From c810329eb0933d70feb611ee39b44f872a524c1b Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Wed, 31 Jan 2024 10:48:52 +0100 Subject: [PATCH 2/2] fmt fix --- examples/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/src/lib.rs b/examples/src/lib.rs index 3a8c73ad48..0da43cfcab 100644 --- a/examples/src/lib.rs +++ b/examples/src/lib.rs @@ -53,7 +53,7 @@ impl From<&CommonArgs> for Config { 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) + None => Ok(None), } .unwrap(); if !value.connect.is_empty() {