Refactor Nix handling and add toggle UI

- Introduce `NixModules` struct containing file paths, parsed ASTs, and
option lists. - Add `parse_nix` and `build_nix_modules` helpers for
centralized parsing. - Update CLI to use `build_nix_modules` instead of
manual parsing. - Extend `App` with system/home paths and ASTs, enabling
in‑place editing. - Implement boolean toggle on Enter: update AST,
rewrite file, refresh modules, and report action. - Simplify event
handling, adding shortcuts `1`/`2` to switch files. - Revise UI layout,
introduce footer with usage hints and last‑action status. - Adjust
imports and remove obsolete code across modules.
This commit is contained in:
2025-12-06 17:21:44 +01:00
parent 19e820ca93
commit 6c50da8c18
4 changed files with 171 additions and 88 deletions

View File

@@ -1,7 +1,7 @@
use garandos_tui::{
app::{App, Event, handle_input_events},
cli::{NixModules, get_modules},
nix::ConfigSource,
cli::get_modules,
nix::{ConfigSource, NixModules},
};
use ratatui::{Terminal, prelude::CrosstermBackend};
use std::{
@@ -15,6 +15,10 @@ fn main() -> Result<()> {
let mut terminal: Terminal<CrosstermBackend<Stdout>> = ratatui::init();
let mut app: App = App {
exit: false,
system_path: nix_modules.system_path,
home_path: nix_modules.home_path,
system_ast: nix_modules.system_ast,
home_ast: nix_modules.home_ast,
system_modules: nix_modules.system_modules,
home_modules: nix_modules.home_modules,
current_file: ConfigSource::System,