Skip to main content

bee_tui/
cli.rs

1use clap::Parser;
2
3use crate::config::{get_config_dir, get_data_dir};
4
5#[derive(Parser, Debug)]
6#[command(author, version = version(), about)]
7pub struct Cli {
8    /// Tick rate, i.e. number of ticks per second
9    #[arg(short, long, value_name = "FLOAT", default_value_t = 4.0)]
10    pub tick_rate: f64,
11
12    /// Frame rate, i.e. number of frames per second
13    #[arg(short, long, value_name = "FLOAT", default_value_t = 60.0)]
14    pub frame_rate: f64,
15
16    /// Render with ASCII glyphs only — no Unicode (✓ ⚠ ✗ ▶ ▇ …).
17    /// Use on terminals with poor Unicode support: Windows Terminal
18    /// pre-Win11, screen readers, some SSH chains. Equivalent to
19    /// setting `[ui].ascii_fallback = true` in `config.toml`.
20    #[arg(long)]
21    pub ascii: bool,
22
23    /// Suppress colour output regardless of the configured theme.
24    /// Equivalent to setting `[ui].theme = "mono"` in `config.toml`,
25    /// or to `NO_COLOR=1` in the environment (which is also honoured
26    /// automatically per <https://no-color.org>).
27    #[arg(long)]
28    pub no_color: bool,
29}
30
31const VERSION_MESSAGE: &str = concat!(
32    env!("CARGO_PKG_VERSION"),
33    "-",
34    env!("VERGEN_GIT_DESCRIBE"),
35    " (",
36    env!("VERGEN_BUILD_DATE"),
37    ")"
38);
39
40pub fn version() -> String {
41    let author = clap::crate_authors!();
42
43    // let current_exe_path = PathBuf::from(clap::crate_name!()).display().to_string();
44    let config_dir_path = get_config_dir().display().to_string();
45    let data_dir_path = get_data_dir().display().to_string();
46
47    format!(
48        "\
49{VERSION_MESSAGE}
50
51Authors: {author}
52
53Config directory: {config_dir_path}
54Data directory: {data_dir_path}"
55    )
56}