Skip to content

Commit

Permalink
Add missing options of z_pub_shm_thr.rs (#550)
Browse files Browse the repository at this point in the history
  • Loading branch information
YuanYuYuan authored Sep 14, 2023
1 parent a341d7d commit dcefe81
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion examples/examples/z_pub_shm_thr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
"<PAYLOAD_SIZE> '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()
Expand Down

0 comments on commit dcefe81

Please sign in to comment.