This commit is contained in:
nora 2024-01-31 21:44:14 +01:00
parent d964157bfc
commit 49c9e3aa4c
6 changed files with 130 additions and 17 deletions

View file

@ -1,12 +1,21 @@
//! `fuf db` commands.
use color_eyre::Result;
use std::{path::Path};
use color_eyre::{eyre::Context, Result};
use std::path::PathBuf;
use crate::{cli::utils, workspace::Workspace};
pub fn save_file(workspace: &Workspace, path: &Path) -> Result<()> {
let file = utils::read_file(path)?;
pub fn save_file(workspace: &Workspace, paths: &[PathBuf]) -> Result<()> {
for path in paths {
let file = utils::read_file(path)?;
let address = workspace
.db
.save_file(&file)
.wrap_err("saving file to database")?;
utils::print(format_args!("{address}\n")).wrap_err("printing output")?;
}
Ok(())
}