Skip to main content

vs_app/
lib.rs

1//! Desktop GUI for the `vs` runtime version manager, built on gpui + gpui-component.
2
3mod model;
4mod service;
5mod ui;
6
7pub use model::{
8    AddSource, BackendChoice, ScopeChoice, ToolRow, VersionRow, available_rows, filter_tool_rows,
9    installed_rows, merge_tool_rows, progress_percent,
10};
11pub use service::AppService;
12
13use anyhow::Result;
14use gpui::{AppContext as _, Application, WindowOptions};
15use gpui_component::Root;
16
17use crate::ui::RootView;
18
19/// Launch the GUI application.
20pub fn run() -> Result<()> {
21    let core = vs_core::App::from_env()?;
22    let service = AppService::new(core);
23
24    Application::new().run(move |cx| {
25        gpui_component::init(cx);
26        let opened = cx.open_window(WindowOptions::default(), |window, cx| {
27            let view = cx.new(|cx| RootView::new(service.clone(), window, cx));
28            cx.new(|cx| Root::new(view, window, cx))
29        });
30        if let Err(err) = opened {
31            eprintln!("vs-app: failed to open window: {err}");
32            cx.quit();
33        }
34    });
35
36    Ok(())
37}