use crate::config::Config;
use crate::container::Backend;
use crate::runtime::Executor;
use std::path::Path;
use std::sync::Arc;
use thiserror::Error;
pub mod ansi;
pub mod app;
pub mod dialogs;
pub mod palette;
pub mod runner;
pub mod services;
pub mod shared;
pub mod syntax;
pub mod ui;
pub mod views;
pub mod watchers;
pub mod worker;
pub mod editor;
mod lazygit;
mod terminal;
#[cfg(test)]
mod test_support;
pub use app::{App, View};
pub use runner::{CapturedLine, RunState};
pub use services::ServicePane;
pub use views::control_center::state::{Item, ItemKind};
pub use watchers::{WatcherPane, WatcherState};
#[derive(Debug, Error)]
pub enum TuiError {
#[error("terminal io: {0}")]
Io(#[from] std::io::Error),
}
pub use terminal::DriveOutcome;
pub async fn run(
config: Arc<Config>,
executor: Executor,
backend: Arc<dyn Backend>,
devcontainer: Option<Arc<crate::container::devcontainer::DevcontainerBackend>>,
project_root: &Path,
initial_view: View,
branch: Option<String>,
) -> Result<DriveOutcome, TuiError> {
let editor_cfg = editor::resolve(&config.editor);
let mut app = App::new(config)
.with_executor(executor)
.with_backend(backend)
.with_project_root(project_root)
.with_branch(branch)
.with_editor(editor_cfg);
if let Some(dc) = devcontainer {
app = app.with_devcontainer(dc);
}
app.spawn_boot_tasks(project_root);
if initial_view != View::ControlCenter {
app.switch_view(initial_view);
}
terminal::run_event_loop(&mut app, initial_view).await
}