twinleaf_tools/cli/
mod.rs1mod capture;
2mod dump;
3mod health;
4mod log;
5mod monitor;
6mod proxy;
7mod rpc;
8mod simulate;
9mod upgrade;
10
11pub use capture::CaptureCli;
12pub use dump::DumpCli;
13pub use health::HealthCli;
14pub use log::{
15 parse_csv_target, CsvTarget, LogCli, LogSubcommands, MetaSubcommands, SplitLevel, SplitPolicy,
16 StreamSel,
17};
18pub use monitor::MonitorCli;
19pub use proxy::{MountArg, ProxyCli, ProxySubcommands};
20pub use rpc::{RPCSubcommands, RpcCli};
21pub use simulate::SimulateCli;
22pub use upgrade::UpgradeCli;
23
24use clap::{Parser, Subcommand};
25use clap_complete::Shell;
26
27pub(crate) fn nonneg_f64(s: &str) -> Result<f64, String> {
28 let v: f64 = s
29 .parse()
30 .map_err(|e: std::num::ParseFloatError| e.to_string())?;
31 if v < 0.0 {
32 Err("must be >= 0".into())
33 } else {
34 Ok(v)
35 }
36}
37
38#[derive(Parser, Debug)]
39#[command(
40 name = "tio",
41 version,
42 about = "Twinleaf sensor management and data logging tool",
43 disable_help_subcommand = true
44)]
45pub struct TioCli {
46 #[command(subcommand)]
47 pub command: Commands,
48}
49
50#[derive(Subcommand, Debug)]
51pub enum Commands {
52 List {
54 #[arg(short = 'a', long = "all")]
56 all: bool,
57 },
58
59 Monitor(MonitorCli),
61
62 Health(HealthCli),
64
65 Dump(DumpCli),
67
68 Log(LogCli),
70
71 Rpc(RpcCli),
73
74 Capture(CaptureCli),
76
77 #[command(alias = "firmware-upgrade")]
79 Upgrade(UpgradeCli),
80
81 Proxy(ProxyCli),
83
84 Simulate(SimulateCli),
86
87 #[command(hide = true)]
89 Test(SimulateCli),
90
91 #[command(long_about = "\
93Generate shell completions for tio.
94
95Add one of these lines to your shell's config file:
96
97 Bash (~/.bashrc):
98 eval \"$(tio completions bash)\"
99
100 Zsh (~/.zshrc):
101 eval \"$(tio completions zsh)\"
102
103 Fish (~/.config/fish/config.fish):
104 tio completions fish | source
105
106 PowerShell ($PROFILE):
107 tio completions powershell | Invoke-Expression")]
108 Completions {
109 #[arg(value_enum)]
110 shell: Shell,
111 },
112}