gravityfile_tui/
lib.rs

1//! Terminal user interface for gravityfile.
2//!
3//! This crate provides an interactive TUI for exploring disk usage,
4//! built with ratatui.
5//!
6//! # Overview
7//!
8//! `gravityfile-tui` provides a feature-rich terminal interface:
9//!
10//! - **Explorer view** - Navigate directory trees sorted by size
11//! - **Duplicates view** - Browse duplicate file groups
12//! - **Age view** - Analyze file age distribution
13//! - **Errors view** - Review scan warnings
14//!
15//! # Usage
16//!
17//! ```rust,no_run
18//! use gravityfile_tui;
19//! use std::path::PathBuf;
20//!
21//! // Run the TUI on a directory
22//! gravityfile_tui::run(PathBuf::from("/path/to/explore")).unwrap();
23//! ```
24//!
25//! # Keyboard Navigation
26//!
27//! - `j`/`k` - Move down/up
28//! - `h`/`l` - Collapse/expand directories
29//! - `Enter` - Drill into directory
30//! - `Backspace` - Navigate back
31//! - `Tab` - Switch view
32//! - `d` - Mark for deletion
33//! - `:` - Command palette
34//! - `?` - Help
35//! - `q` - Quit
36
37pub mod app;
38mod event;
39mod theme;
40mod ui;
41
42pub use app::{App, AppResult};
43pub use theme::Theme;
44
45/// Run the TUI application.
46pub fn run(path: std::path::PathBuf) -> AppResult<()> {
47    // Create tokio runtime for async operations
48    let rt = tokio::runtime::Runtime::new()?;
49
50    let terminal = ratatui::init();
51    let result = rt.block_on(App::new(path).run(terminal));
52    ratatui::restore();
53
54    // Shutdown runtime immediately to cancel background tasks
55    rt.shutdown_timeout(std::time::Duration::from_millis(100));
56
57    result
58}