Skip to main content

twinleaf_tools/
lib.rs

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