open with path

This commit is contained in:
thatscringebro
2026-03-12 09:41:23 -04:00
parent 30880ed104
commit bf1de016cd
2 changed files with 14 additions and 4 deletions

View File

@@ -16,8 +16,8 @@ pub struct App {
} }
impl App { impl App {
pub fn new() -> App { pub fn new(path: &str) -> App {
let con = match Connection::open("ft_rs.db") { let con = match Connection::open(path) {
Ok(con) => con, Ok(con) => con,
Err(e) => { Err(e) => {
eprintln!("Error opening database: {}", e); eprintln!("Error opening database: {}", e);

View File

@@ -15,15 +15,25 @@ use ratatui::{
}, },
prelude::Backend, prelude::Backend,
}; };
use std::{error::Error, io}; use std::{
env::{self},
error::Error,
io,
};
fn main() -> Result<(), Box<dyn Error>> { fn main() -> Result<(), Box<dyn Error>> {
enable_raw_mode()?; enable_raw_mode()?;
let mut stderr = io::stderr(); let mut stderr = io::stderr();
execute!(stderr, EnterAlternateScreen, EnableMouseCapture)?; execute!(stderr, EnterAlternateScreen, EnableMouseCapture)?;
let mut path: &str = "ft_rs.db";
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
path = &args[1];
}
let mut terminal = ratatui::init(); let mut terminal = ratatui::init();
let mut app = App::new(); let mut app = App::new(path);
let res = run_app(&mut terminal, &mut app); let res = run_app(&mut terminal, &mut app);
disable_raw_mode()?; disable_raw_mode()?;