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 thiserror::Error;
use ghee::{ 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::{ parser::{
assignment::{Assignment, AssignmentParser}, assignment::{Assignment, AssignmentParser},
key::Key, key::Key,
@ -223,7 +223,7 @@ fn run_command(cmd: &Commands) {
fields, fields,
verbose, verbose,
} => { } => {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Copy); cp(src, dest, fields, verbose);
} }
Commands::Mv { Commands::Mv {
src, src,
@ -231,7 +231,7 @@ fn run_command(cmd: &Commands) {
fields, fields,
verbose, verbose,
} => { } => {
cp_or_mv(src, dest, fields, verbose, CopyOrMove::Move); mv(src, dest, fields, verbose);
} }
Commands::Rm { Commands::Rm {
paths, 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, Move,
} }
pub fn cp_or_mv( pub(crate) fn cp_or_mv(
src: &PathBuf, src: &PathBuf,
dest: &PathBuf, dest: &PathBuf,
fields: &Vec<Xattr>, fields: &Vec<Xattr>,

View file

@ -1,3 +1,4 @@
mod cp;
mod cp_or_mv; mod cp_or_mv;
mod del; mod del;
mod get; mod get;
@ -5,14 +6,16 @@ mod idx;
mod init; mod init;
mod ins; mod ins;
mod ls; mod ls;
mod mv;
mod rm; mod rm;
mod set; mod set;
pub use cp_or_mv::{cp_or_mv, CopyOrMove}; pub use cp::cp;
pub use del::del; pub use del::del;
pub use get::get; pub use get::get;
pub use idx::idx; pub use idx::idx;
pub use init::init; pub use init::init;
pub use ins::ins; pub use ins::ins;
pub use ls::ls; pub use ls::ls;
pub use mv::mv;
pub use rm::rm; pub use rm::rm;
pub use set::set; 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);
}