Expose distinct cp and mv; hide cp_or_mv from public interface

This commit is contained in:
Josh Hansen 2023-09-05 19:57:19 -07:00
parent a84f06ff29
commit febc9b9de7
5 changed files with 26 additions and 5 deletions

View file

@ -6,7 +6,7 @@ use rustyline::DefaultEditor;
use thiserror::Error;
use ghee::{
cmd::{cp_or_mv, del, get, idx, init, ins, ls, rm, set, CopyOrMove},
cmd::{cp, del, get, idx, init, ins, ls, mv, rm, set},
parser::{
assignment::{Assignment, AssignmentParser},
key::Key,
@ -223,7 +223,7 @@ fn run_command(cmd: &Commands) {
fields,
verbose,
} => {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Copy);
cp(src, dest, fields, verbose);
}
Commands::Mv {
src,
@ -231,7 +231,7 @@ fn run_command(cmd: &Commands) {
fields,
verbose,
} => {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Move);
mv(src, dest, fields, verbose);
}
Commands::Rm {
paths,

9
src/cmd/cp.rs Normal file
View file

@ -0,0 +1,9 @@
use std::path::PathBuf;
use crate::parser::xattr::Xattr;
use super::cp_or_mv::{cp_or_mv, CopyOrMove};
pub fn cp(src: &PathBuf, dest: &PathBuf, fields: &Vec<Xattr>, verbose: &bool) {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Copy);
}

View file

@ -8,7 +8,7 @@ pub enum CopyOrMove {
Move,
}
pub fn cp_or_mv(
pub(crate) fn cp_or_mv(
src: &PathBuf,
dest: &PathBuf,
fields: &Vec<Xattr>,

View file

@ -1,3 +1,4 @@
mod cp;
mod cp_or_mv;
mod del;
mod get;
@ -5,14 +6,16 @@ mod idx;
mod init;
mod ins;
mod ls;
mod mv;
mod rm;
mod set;
pub use cp_or_mv::{cp_or_mv, CopyOrMove};
pub use cp::cp;
pub use del::del;
pub use get::get;
pub use idx::idx;
pub use init::init;
pub use ins::ins;
pub use ls::ls;
pub use mv::mv;
pub use rm::rm;
pub use set::set;

9
src/cmd/mv.rs Normal file
View file

@ -0,0 +1,9 @@
use std::path::PathBuf;
use crate::parser::xattr::Xattr;
use super::cp_or_mv::{cp_or_mv, CopyOrMove};
pub fn mv(src: &PathBuf, dest: &PathBuf, fields: &Vec<Xattr>, verbose: &bool) {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Move);
}