diff --git a/examples/examples/z_pub_shm_thr.rs b/examples/examples/z_pub_shm_thr.rs index 44c2c1fc2b..2da0cf102c 100644 --- a/examples/examples/z_pub_shm_thr.rs +++ b/examples/examples/z_pub_shm_thr.rs @@ -47,18 +47,44 @@ fn parse_args() -> (Config, usize, usize) { Arg::from_usage("-s, --shared-memory=[MB] 'shared memory size in MBytes'") .default_value("32"), ) + .arg( + Arg::from_usage("-m, --mode=[MODE] 'The zenoh session mode (peer by default).") + .possible_values(["peer", "client"]), + ) .arg(Arg::from_usage( "-e, --connect=[ENDPOINT]... 'Endpoints to connect to.'", )) + .arg(Arg::from_usage( + "-l, --listen=[ENDPOINT]... 'Endpoints to listen on.'", + )) .arg(Arg::from_usage( "-c, --config=[FILE] 'A configuration file.'", )) .arg(Arg::from_usage( " 'Sets the size of the payload to publish'", )) + .arg(Arg::from_usage( + "--no-multicast-scouting 'Disable the multicast-based scouting mechanism.'", + )) .get_matches(); - let config = Config::default(); + let mut config = if let Some(conf_file) = args.value_of("config") { + Config::from_file(conf_file).unwrap() + } else { + Config::default() + }; + if let Some(Ok(mode)) = args.value_of("mode").map(|mode| mode.parse()) { + config.set_mode(Some(mode)).unwrap(); + } + if let Some(values) = args.values_of("connect") { + config.connect.endpoints = values.map(|v| v.parse().unwrap()).collect(); + } + if let Some(values) = args.values_of("listen") { + config.listen.endpoints = values.map(|v| v.parse().unwrap()).collect(); + } + if args.is_present("no-multicast-scouting") { + config.scouting.multicast.set_enabled(Some(false)).unwrap(); + } let sm_size = args .value_of("shared-memory") .unwrap()