use anyhow::{Context, Result};
use clap::Parser;
use gpu_histop::backend::create_backend;
use gpu_histop::config::Args;
use gpu_histop::gui::{GuiApp, GuiConfig};
use gpu_histop::sampler::spawn_sampler;
fn main() -> Result<()> {
let args = Args::parse();
let backend =
create_backend(args.backend).with_context(|| "failed to initialize GPU metrics backend")?;
let backend_label = backend.label().to_owned();
let devices = backend.devices().to_vec();
let (rx, sampler) = spawn_sampler(backend, args.sample_interval());
let app = GuiApp::new(
devices,
backend_label,
rx,
sampler,
GuiConfig {
sample_interval: args.sample_interval(),
frame_interval: args.frame_interval(),
history_retention: args.history_retention(),
initial_window: args.window(),
},
);
gpu_histop::gui::run(app)
}