From 1de9d369c2ef340cc87e7afc231f3d0bbb2f5176 Mon Sep 17 00:00:00 2001 From: Julien Enoch Date: Wed, 31 Jan 2024 11:21:58 +0100 Subject: [PATCH] Examples: fix overwritten mode in config file (fix #700) (#702) --- 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..0da43cfcab 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() {