Added function to create file for database if one does not exist
This commit is contained in:
parent
ebbde2214a
commit
aaa9d542b6
1 changed files with 11 additions and 0 deletions
11
src/main.rs
11
src/main.rs
|
|
@ -1,6 +1,8 @@
|
|||
mod cli;
|
||||
mod db;
|
||||
|
||||
use std::{fs::File, path::Path};
|
||||
|
||||
use anyhow::anyhow;
|
||||
use clap::Parser;
|
||||
use cli::Cli;
|
||||
|
|
@ -16,6 +18,15 @@ async fn main() -> Result<()> {
|
|||
Please provide one with the BOOKMARK_DB_PATH environment \
|
||||
variable.".to_string()
|
||||
))?;
|
||||
create_if_not_exists(&location)?;
|
||||
let store = db::Store::new(&location, cli.is_reading_list).await?;
|
||||
cli.run(store).await
|
||||
}
|
||||
|
||||
fn create_if_not_exists(path_string: &str) -> Result<()> {
|
||||
let path = Path::new(path_string);
|
||||
if !path.is_file() {
|
||||
File::create(path)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue