From ed0baec0a3f953c99445f6842dadc5566e89cb75 Mon Sep 17 00:00:00 2001 From: diogo464 Date: Thu, 8 Jul 2021 17:11:46 -0400 Subject: Initial commit --- dotup_cli/src/commands/uninstall.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 dotup_cli/src/commands/uninstall.rs (limited to 'dotup_cli/src/commands/uninstall.rs') diff --git a/dotup_cli/src/commands/uninstall.rs b/dotup_cli/src/commands/uninstall.rs new file mode 100644 index 0000000..dad55a5 --- /dev/null +++ b/dotup_cli/src/commands/uninstall.rs @@ -0,0 +1,31 @@ +use clap::Clap; +use std::path::PathBuf; + +use super::prelude::*; + +#[derive(Clap)] +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(required = true, min_values = 1)] + 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)?; + } + + Ok(()) +} -- cgit