1#![cfg(windows)]
2
3use anyhow::Result;
16use std::io;
17
18pub mod cli;
19pub mod commands;
20pub mod services;
21
22use winbrew_app::AppContext;
23use winbrew_ui::{Ui, UiSettings};
24
25pub(crate) use winbrew_app as app;
26pub use winbrew_app::core::cancel;
27pub use winbrew_app::{core, database, engines, models};
28
29#[derive(Debug, Clone)]
30pub struct CommandContext {
31 app: AppContext,
32 ui: UiSettings,
33}
34
35impl CommandContext {
36 pub fn from_config(config: &database::Config) -> Result<Self> {
38 Self::from_config_with_verbosity(config, 0)
39 }
40
41 pub fn from_config_with_verbosity(config: &database::Config, verbosity: u8) -> Result<Self> {
43 Ok(Self {
44 app: AppContext::from_config_with_verbosity(config, verbosity)?,
45 ui: UiSettings {
46 color_enabled: config.core.color,
47 default_yes: config.core.default_yes,
48 },
49 })
50 }
51
52 pub fn ui(&self) -> Ui<io::Stdout> {
54 Ui::new(self.ui)
55 }
56
57 pub fn app(&self) -> &AppContext {
59 &self.app
60 }
61}
62
63pub fn run_app(command: crate::cli::Command, verbosity: u8) -> Result<()> {
65 services::startup::run(command, verbosity)
66}