From aad48aa44646905d4fab8c51770a5d932360fda4 Mon Sep 17 00:00:00 2001 From: Henrique Alves Date: Sun, 31 Jul 2022 16:41:27 -0300 Subject: Add no_copy flag --- src/commands.rs | 12 ++++++------ src/main.rs | 33 +++++++++++++++------------------ 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index a3425e4..ba4b18c 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -64,7 +64,7 @@ pub fn check_ignores(root : &str) { } } -pub fn install_all_packages(root : &str, verbose : bool) { +pub fn install_all_packages(root : &str, verbose : bool, copy_files : bool) { let glam_file_path = format!("{}/.glam", root); // Find glam object or create one with default configuration @@ -75,7 +75,7 @@ pub fn install_all_packages(root : &str, verbose : bool) { utils::log_info(&format!("Installing {}...", package.name)); clone_or_fetch_package(root, &package, verbose); let commit = package.commit.to_string(); - install_glam_package(root, &commit, package, false, true, verbose); + install_glam_package(root, &commit, package, false, copy_files, verbose); } // Write .glam file @@ -126,7 +126,7 @@ pub fn install_package(root : &str, git_repo : &str, commit : &str, copy_files : write_glam_file(&glam_file_path, &glam_object); } -pub fn update_all_packages(root : &str, verbose : bool) { +pub fn update_all_packages(root : &str, verbose : bool, copy_files : bool) { let glam_file_path = format!("{}/.glam", root); // Find glam object or create one with default configuration @@ -136,14 +136,14 @@ pub fn update_all_packages(root : &str, verbose : bool) { for package in glam_packages.iter_mut() { utils::log_info(&format!("Updating {}...", package.name)); clone_or_fetch_package(root, &package, verbose); - install_glam_package(root, "", package, true, true, verbose); + install_glam_package(root, "", package, true, copy_files, verbose); } glam_object.packages = glam_packages; write_glam_file(&glam_file_path, &glam_object); } -pub fn update_package(root : &str, package_name : &str, verbose : bool) { +pub fn update_package(root : &str, package_name : &str, verbose : bool, copy_files : bool) { let glam_file_path = format!("{}/.glam", root); // Find package to update @@ -162,7 +162,7 @@ pub fn update_package(root : &str, package_name : &str, verbose : bool) { let target_package = &mut glam_packages[package_index]; clone_or_fetch_package(root, &target_package, verbose); - install_glam_package(root, "", target_package, true, true, verbose); + install_glam_package(root, "", target_package, true, copy_files, verbose); // Write .glam file glam_object.packages = glam_packages; diff --git a/src/main.rs b/src/main.rs index 6bd6410..8584779 100644 --- a/src/main.rs +++ b/src/main.rs @@ -31,28 +31,25 @@ enum Commands { /// Install all packages on .glam file Install { - // TODO: no_copy flag - //// Don't copy to target folder - // #[clap(short, long, required = false, takes_value = false)] - // no_copy: bool, + /// Don't copy to target folder + #[clap(short, long, required = false, takes_value = false)] + no_copy: bool, }, /// Update a single GLAM package UpdatePackage { /// Name of the package to update (default is all packages) package_name: String, - // TODO: no_copy flag - //// Don't copy to target folder - // #[clap(short, long, required = false, takes_value = false)] - // no_copy: bool, + /// Don't copy to target folder + #[clap(short, long, required = false, takes_value = false)] + no_copy: bool, }, /// Update all GLAM packages Update { - // TODO: no_copy flag - //// Don't copy to target folder - // #[clap(short, long, required = false, takes_value = false)] - // no_copy: bool, + /// Don't copy to target folder + #[clap(short, long, required = false, takes_value = false)] + no_copy: bool, }, /// Remove a GLAM package @@ -86,25 +83,25 @@ fn main() { commands::install_package(&root, git_repo, commit, !*no_copy, cli.verbose); }, - Commands::Install { } => { + Commands::Install { no_copy } => { let root = commands::search_project_root(); commands::check_ignores(&root); commands::initialize_glam_files(&root); - commands::install_all_packages(&root, cli.verbose); + commands::install_all_packages(&root, cli.verbose, !*no_copy); }, - Commands::UpdatePackage { package_name } => { + Commands::UpdatePackage { package_name, no_copy } => { let root = commands::search_project_root(); commands::check_ignores(&root); commands::initialize_glam_files(&root); - commands::update_package(&root, &package_name, cli.verbose); + commands::update_package(&root, &package_name, cli.verbose, !*no_copy); }, - Commands::Update {} => { + Commands::Update { no_copy } => { let root = commands::search_project_root(); commands::check_ignores(&root); commands::initialize_glam_files(&root); - commands::update_all_packages(&root, cli.verbose); + commands::update_all_packages(&root, cli.verbose, !*no_copy); }, Commands::RemovePackage {package_name} => { -- cgit v1.2.3