1use clap::Parser;
2use tio::proto::DeviceRoute;
3use tio::util;
4use twinleaf::tio;
5
6#[derive(Parser, Debug, Clone)]
7pub struct TioOpts {
8 #[arg(
10 short = 'r',
11 long = "root",
12 default_value_t = util::default_proxy_url().to_string(),
13 help = "Sensor root address"
14 )]
15 pub root: String,
16
17 #[arg(
19 short = 's',
20 long = "sensor",
21 default_value = "/",
22 help = "Sensor path in the sensor tree"
23 )]
24 pub route_path: String,
25}
26
27impl TioOpts {
28 pub fn parse_route(&self) -> DeviceRoute {
29 DeviceRoute::from_str(&self.route_path).unwrap_or_else(|_| DeviceRoute::root())
30 }
31}