From f20662e3a255af07b295b851c2b866853e503856 Mon Sep 17 00:00:00 2001 From: Ian Date: Wed, 10 Dec 2025 21:10:17 -0500 Subject: [PATCH] adding precheck method, is_git_installed --- README.md | 3 ++- src/main.rs | 14 ++++++++++++-- src/utils.rs | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 src/utils.rs diff --git a/README.md b/README.md index cc18345..930d858 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,10 @@ 2. `cd ducke` -3. For debug : `cargo build` +3. For debug (or to build locally): `cargo build` For release: `cargo build --release` + 4. To run debug : `./target/debug/ducke` To run release : `./target/release/ducke` diff --git a/src/main.rs b/src/main.rs index 6d17dbf..2e61759 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,21 @@ use crossterm::event::{self, Event}; use ratatui::{Frame, text::Text}; +mod utils; fn main() { + // Check for git BEFORE initializing the terminal + if !utils::is_git_installed() { + eprintln!("Error: Git is not installed or not in PATH"); + eprintln!("Please install Git to use this application. For details see: https://git-scm.com/install/"); + std::process::exit(1); + } + + println!("✓ Git is installed and ready!"); + std::thread::sleep(std::time::Duration::from_secs(3)); + let mut terminal = ratatui::init(); loop { terminal.draw(draw).expect("failed to draw frame"); - if matches!(event::read().expect("failed to read event"), Event::Key(_)) { break; } @@ -16,4 +26,4 @@ fn main() { fn draw(frame: &mut Frame) { let text = Text::raw("Hello, World!"); frame.render_widget(text, frame.area()); -} +} \ No newline at end of file diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..c7554a5 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,9 @@ +use std::process::Command; + +pub fn is_git_installed() -> bool { + Command::new("git") + .arg("--version") + .output() + .map(|output| output.status.success()) + .unwrap_or(false) +} \ No newline at end of file