pub(super) mod dispatch;
pub(super) mod driver;
pub(super) mod gitignore;
pub(super) mod render;
pub(super) mod tree_io;
use std::ffi::OsString;
use std::path::{Path, PathBuf};
use miette::Result;
use super::commit::CommitPlan;
use super::model::{Node, Tree};
use crate::commands::init::tui::gitignore::GitignoreMatcher;
use crate::commands::init::tui::tree_io::read_dir_children;
pub use crate::commands::init::tui::driver::run_interactive_scaffold;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum DispatchResult {
Continue,
LoadChildrenThenRetryExpand,
LoadChildrenThenRetryCycle,
ReloadTreeForVisibility,
ExitCommit,
ExitCancel,
Abort,
}
#[derive(Debug)]
pub enum ScaffoldOutcome {
Confirmed(CommitPlan),
Declined,
Aborted,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TuiFocus {
Tree,
CommitButton,
}
#[derive(Debug)]
pub struct TuiState {
pub tree: Tree,
pub focus: TuiFocus,
pub cwd_host: PathBuf,
pub gitignore: GitignoreMatcher,
pub hidden_visible: bool,
pub status: Option<String>,
pub help_visible: bool,
pub bell_pending: bool,
}
impl TuiState {
fn new(cwd_host: PathBuf) -> Result<Self> {
let gitignore = GitignoreMatcher::new(&cwd_host);
let children = read_dir_children(&cwd_host, Path::new("/"), &gitignore, false)?;
let mut root = Node::new(OsString::from("/"), PathBuf::from("/"));
root.children = children;
root.children_loaded = true;
root.expanded = true;
Ok(Self {
tree: Tree::new(root),
focus: TuiFocus::Tree,
cwd_host,
gitignore,
hidden_visible: false,
status: None,
help_visible: false,
bell_pending: false,
})
}
}