brewery
notashelf /
ccc30d1bbdf943a485a4a478f0f80165eaec3571

beer

public

A terminal worth pouring time into

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