hardcopy subcommand add
This commit is contained in:
24
src/main.rs
24
src/main.rs
@ -37,6 +37,22 @@ fn main() {
|
|||||||
.action(clap::ArgAction::SetTrue),
|
.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();
|
.get_matches();
|
||||||
|
|
||||||
if let Some(install_matches) = matches.subcommand_matches("install") {
|
if let Some(install_matches) = matches.subcommand_matches("install") {
|
||||||
@ -64,6 +80,14 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
commands::delete::delete(repo, pkgname);
|
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 {
|
} else {
|
||||||
println!("No command provided. Use `pkg --help` for usage information.");
|
println!("No command provided. Use `pkg --help` for usage information.");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user