mod capture;
mod dump;
mod health;
mod log;
mod monitor;
mod proxy;
mod rpc;
mod simulate;
mod upgrade;
pub use capture::CaptureCli;
pub use dump::DumpCli;
pub use health::HealthCli;
pub use log::{
parse_csv_target, CsvTarget, LogCli, LogSubcommands, MetaSubcommands, SplitLevel, SplitPolicy,
StreamSel,
};
pub use monitor::MonitorCli;
pub use proxy::{MountArg, ProxyCli, ProxySubcommands};
pub use rpc::{RPCSubcommands, RpcCli};
pub use simulate::SimulateCli;
pub use upgrade::UpgradeCli;
use clap::{Parser, Subcommand};
use clap_complete::Shell;
pub(crate) fn nonneg_f64(s: &str) -> Result<f64, String> {
let v: f64 = s
.parse()
.map_err(|e: std::num::ParseFloatError| e.to_string())?;
if v < 0.0 {
Err("must be >= 0".into())
} else {
Ok(v)
}
}
#[derive(Parser, Debug)]
#[command(
name = "tio",
version,
about = "Twinleaf sensor management and data logging tool",
disable_help_subcommand = true
)]
pub struct TioCli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
List {
#[arg(short = 'a', long = "all")]
all: bool,
},
Monitor(MonitorCli),
Health(HealthCli),
Dump(DumpCli),
Log(LogCli),
Rpc(RpcCli),
Capture(CaptureCli),
#[command(alias = "firmware-upgrade")]
Upgrade(UpgradeCli),
Proxy(ProxyCli),
Simulate(SimulateCli),
#[command(hide = true)]
Test(SimulateCli),
#[command(long_about = "\
Generate shell completions for tio.
Add one of these lines to your shell's config file:
Bash (~/.bashrc):
eval \"$(tio completions bash)\"
Zsh (~/.zshrc):
eval \"$(tio completions zsh)\"
Fish (~/.config/fish/config.fish):
tio completions fish | source
PowerShell ($PROFILE):
tio completions powershell | Invoke-Expression")]
Completions {
#[arg(value_enum)]
shell: Shell,
},
}