brewery
notashelf /
932b14bbfc37bfdc8da9fd258e078acebd2eff92

beer

public

A terminal worth pouring time into

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/beer.git
src/main.rsRust66 lines1.4 KB
1
//! beer, a fast, software-rendered, Wayland-native terminal emulator.
2
3
mod bindings;
4
mod config;
5
mod font;
6
mod grid;
7
mod input;
8
mod pty;
9
mod render;
10
mod theme;
11
mod vt;
12
mod wayland;
13
14
use std::path::PathBuf;
15
use std::process::ExitCode;
16
17
use pound::Parse;
18
19
use crate::config::Config;
20
21
/// A fast, software-rendered, Wayland-native terminal emulator.
22
#[derive(Parse)]
23
#[pound(name = "beer", version = "0.0.0")]
24
struct Cli {
25
    /// Run as a daemon hosting multiple windows.
26
    #[pound(long)]
27
    server: bool,
28
    /// Path to a config file (default: $XDG_CONFIG_HOME/beer/beer.toml).
29
    #[pound(long)]
30
    config: Option<PathBuf>,
31
}
32
33
fn main() -> ExitCode {
34
    init_logging();
35
    match run(Cli::parse()) {
36
        Ok(code) => code,
37
        Err(err) => {
38
            tracing::error!("{err:#}");
39
            eprintln!("beer: {err:#}");
40
            ExitCode::FAILURE
41
        }
42
    }
43
}
44
45
fn init_logging() {
46
    use tracing_subscriber::{EnvFilter, fmt};
47
48
    let filter = EnvFilter::try_from_env("BEER_LOG")
49
        .or_else(|_| EnvFilter::try_from_default_env())
50
        .unwrap_or_else(|_| EnvFilter::new("warn"));
51
52
    fmt()
53
        .with_env_filter(filter)
54
        .with_writer(std::io::stderr)
55
        .init();
56
}
57
58
fn run(cli: Cli) -> anyhow::Result<ExitCode> {
59
    if cli.server {
60
        anyhow::bail!("server mode is not implemented yet");
61
    }
62
63
    let config = Config::load(cli.config.as_deref());
64
    tracing::info!("starting beer");
65
    wayland::run(config, cli.config)
66
}