From 6817631ddee3795af3a558bf38e477da4ae5b1cb Mon Sep 17 00:00:00 2001 From: diogo464 Date: Fri, 24 Dec 2021 21:09:44 +0000 Subject: made install-path a global option --- dotup_cli/src/commands/install.rs | 11 +---------- dotup_cli/src/commands/status.rs | 8 +++----- dotup_cli/src/commands/uninstall.rs | 11 +---------- 3 files changed, 5 insertions(+), 25 deletions(-) (limited to 'dotup_cli/src/commands') diff --git a/dotup_cli/src/commands/install.rs b/dotup_cli/src/commands/install.rs index e166a7b..6d9fbf7 100644 --- a/dotup_cli/src/commands/install.rs +++ b/dotup_cli/src/commands/install.rs @@ -8,26 +8,17 @@ use super::prelude::*; /// If a file or directory already exists at the location a link would be installed this command will fail. #[derive(Parser)] pub struct Opts { - /// The location where links will be installed to. - /// Defaults to the home directory. - #[clap(long)] - install_base: Option, - /// The files/directories to install. #[clap(min_values = 1, default_value = ".")] paths: Vec, } pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { - let install_base = match opts.install_base { - Some(path) => path, - None => utils::home_directory()?, - }; let depot = utils::read_depot(&config.archive_path)?; for link in utils::collect_links_by_base_paths(&depot, &opts.paths) { log::info!("Installing link {}", link); - depot.install_link(link, &install_base)?; + depot.install_link(link, &config.install_path)?; } Ok(()) diff --git a/dotup_cli/src/commands/status.rs b/dotup_cli/src/commands/status.rs index e05ada9..b7221db 100644 --- a/dotup_cli/src/commands/status.rs +++ b/dotup_cli/src/commands/status.rs @@ -25,7 +25,7 @@ pub struct Opts { #[derive(Debug)] struct State { max_depth: u32, - install_base: PathBuf, + install_path: PathBuf, } pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { @@ -67,9 +67,7 @@ pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { let state = State { max_depth: u32::MAX, - install_base: opts - .install_base - .unwrap_or(utils::home_directory().unwrap()), + install_path: config.install_path, }; let (directories, files) = utils::collect_read_dir_split(".")?; @@ -142,7 +140,7 @@ fn print_link(depot: &Depot, state: &State, link: &Link, depth: u32) { }; print_identation(depth); - if depot.is_link_installed(link, &state.install_base) { + if depot.is_link_installed(link, &state.install_path) { println!( "{} -> {}", Colour::Green.paint(&format!("{}", filename.to_string_lossy())), diff --git a/dotup_cli/src/commands/uninstall.rs b/dotup_cli/src/commands/uninstall.rs index fdb1a0a..fe44bf0 100644 --- a/dotup_cli/src/commands/uninstall.rs +++ b/dotup_cli/src/commands/uninstall.rs @@ -9,26 +9,17 @@ use super::prelude::*; /// Symlinks are only deleted if they were pointing to the correct file. #[derive(Parser)] pub struct Opts { - /// The location where links will be uninstalled from. - /// Defaults to home directory. - #[clap(long)] - install_base: Option, - /// The files/directories to uninstall. #[clap(min_values = 1, default_value = ".")] paths: Vec, } pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { - let install_base = match opts.install_base { - Some(path) => path, - None => utils::home_directory()?, - }; let depot = utils::read_depot(&config.archive_path)?; for link in utils::collect_links_by_base_paths(&depot, &opts.paths) { log::info!("Uninstalling link : {}", link); - depot.uninstall_link(link, &install_base)?; + depot.uninstall_link(link, &config.install_path)?; } Ok(()) -- cgit