hardcopy subcommand add

This commit is contained in:
2025-06-08 12:04:43 +03:00
parent b8fcbe2909
commit e90430f52c

View File

@ -37,6 +37,22 @@ fn main() {
.action(clap::ArgAction::SetTrue),
),
)
.subcommand(
clap::Command::new("hardcopy")
.about("Create a hard link or copy directory structure")
.arg(
clap::Arg::new("source")
.help("Source path")
.required(true)
.index(1),
)
.arg(
clap::Arg::new("destination")
.help("Destination path")
.required(true)
.index(2),
),
)
.get_matches();
if let Some(install_matches) = matches.subcommand_matches("install") {
@ -64,6 +80,14 @@ fn main() {
} else {
commands::delete::delete(repo, pkgname);
}
} else if let Some(hardcopy_matches) = matches.subcommand_matches("hardcopy") {
let source_path = std::path::Path::new(hardcopy_matches.get_one::<String>("source").unwrap());
let destination_path = std::path::Path::new(hardcopy_matches.get_one::<String>("destination").unwrap());
match utils::hardcopy::hardcopy(source_path, destination_path) {
Ok(_) => println!("Hardcopy completed successfully."),
Err(e) => eprintln!("Error during hardcopy: {}", e),
}
} else {
println!("No command provided. Use `pkg --help` for usage information.");
}