diff --git a/Cargo.lock b/Cargo.lock index cf4f021..b3baf53 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -275,7 +275,7 @@ dependencies = [ [[package]] name = "gitten" -version = "0.2.2" +version = "0.2.3" dependencies = [ "crossbeam-channel 0.4.4", "crossterm", diff --git a/Cargo.toml b/Cargo.toml index df41d90..a1f3682 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "gitten" -version = "0.2.2" +version = "0.2.3" edition = "2021" authors = ["okhuz "] license = "MIT" @@ -26,3 +26,4 @@ futures = "0.3.21" [profile.release] opt-level = 3 debug = true +panic = 'abort' \ No newline at end of file diff --git a/src/app.rs b/src/app.rs index 678fe0a..1e706bd 100644 --- a/src/app.rs +++ b/src/app.rs @@ -182,9 +182,8 @@ pub struct App { } impl App { - pub fn new() -> App { + pub fn new(path: String) -> App { let mut content = Vec::new(); - let path = std::env::args().nth(1).unwrap_or_else(|| "./".to_string()); App::generate_application_content(&path, &mut content); diff --git a/src/main.rs b/src/main.rs index d3ec163..f1f19d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ mod repo; use app::App; use run_app::run_app; use std::{io}; +use std::path::Path; use std::time::Duration; use crossterm::event::{DisableMouseCapture, EnableMouseCapture}; use crossterm::execute; @@ -17,13 +18,18 @@ use tui::{backend::CrosstermBackend, Terminal}; fn main() -> Result<(), io::Error> { + let path = std::env::args().nth(1).unwrap_or_else(|| "./".to_string()); + if !Path::new(&path).exists() { + panic!("Path does not exists!"); + } + enable_raw_mode()?; let mut stdout = io::stdout(); execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?; let backend = CrosstermBackend::new(stdout); let mut terminal = Terminal::new(backend)?; - let app = App::new(); + let app = App::new(path); let _ = run_app(&mut terminal, app, Duration::from_millis(5000)); disable_raw_mode()?;