bee_tui/cli.rs
1use std::path::PathBuf;
2
3use clap::Parser;
4
5use crate::config::{get_config_dir, get_data_dir};
6
7#[derive(Parser, Debug)]
8#[command(author, version = version(), about)]
9pub struct Cli {
10 /// Tick rate, i.e. number of ticks per second
11 #[arg(short, long, value_name = "FLOAT", default_value_t = 4.0)]
12 pub tick_rate: f64,
13
14 /// Frame rate, i.e. number of frames per second
15 #[arg(short, long, value_name = "FLOAT", default_value_t = 60.0)]
16 pub frame_rate: f64,
17
18 /// Render with ASCII glyphs only — no Unicode (✓ ⚠ ✗ ▶ ▇ …).
19 /// Use on terminals with poor Unicode support: Windows Terminal
20 /// pre-Win11, screen readers, some SSH chains. Equivalent to
21 /// setting `[ui].ascii_fallback = true` in `config.toml`.
22 #[arg(long)]
23 pub ascii: bool,
24
25 /// Suppress colour output regardless of the configured theme.
26 /// Equivalent to setting `[ui].theme = "mono"` in `config.toml`,
27 /// or to `NO_COLOR=1` in the environment (which is also honoured
28 /// automatically per <https://no-color.org>).
29 #[arg(long)]
30 pub no_color: bool,
31
32 /// Path to a `bee` binary to spawn before opening the cockpit.
33 /// When set together with `--bee-config`, bee-tui starts Bee as
34 /// a child process, captures its log into a temp file, waits for
35 /// the API to come up, then opens the cockpit. Overrides
36 /// `[bee].bin` from `config.toml`.
37 #[arg(long, value_name = "PATH")]
38 pub bee_bin: Option<PathBuf>,
39
40 /// Path to the Bee YAML config the spawned binary should use.
41 /// Required when `--bee-bin` is set unless `[bee].config` is
42 /// already in `config.toml`. Overrides `[bee].config`.
43 #[arg(long, value_name = "PATH")]
44 pub bee_config: Option<PathBuf>,
45}
46
47const VERSION_MESSAGE: &str = concat!(
48 env!("CARGO_PKG_VERSION"),
49 "-",
50 env!("VERGEN_GIT_DESCRIBE"),
51 " (",
52 env!("VERGEN_BUILD_DATE"),
53 ")"
54);
55
56pub fn version() -> String {
57 let author = clap::crate_authors!();
58
59 // let current_exe_path = PathBuf::from(clap::crate_name!()).display().to_string();
60 let config_dir_path = get_config_dir().display().to_string();
61 let data_dir_path = get_data_dir().display().to_string();
62
63 format!(
64 "\
65{VERSION_MESSAGE}
66
67Authors: {author}
68
69Config directory: {config_dir_path}
70Data directory: {data_dir_path}"
71 )
72}