diff options
Diffstat (limited to 'dotup_cli/src/commands/uninstall.rs')
| -rw-r--r-- | dotup_cli/src/commands/uninstall.rs | 31 |
1 files changed, 31 insertions, 0 deletions
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 @@ | |||
| 1 | use clap::Clap; | ||
| 2 | use std::path::PathBuf; | ||
| 3 | |||
| 4 | use super::prelude::*; | ||
| 5 | |||
| 6 | #[derive(Clap)] | ||
| 7 | pub struct Opts { | ||
| 8 | /// The location where links will be uninstalled from. | ||
| 9 | /// Defaults to home directory. | ||
| 10 | #[clap(long)] | ||
| 11 | install_base: Option<PathBuf>, | ||
| 12 | |||
| 13 | /// The files/directories to uninstall | ||
| 14 | #[clap(required = true, min_values = 1)] | ||
| 15 | paths: Vec<PathBuf>, | ||
| 16 | } | ||
| 17 | |||
| 18 | pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { | ||
| 19 | let install_base = match opts.install_base { | ||
| 20 | Some(path) => path, | ||
| 21 | None => utils::home_directory()?, | ||
| 22 | }; | ||
| 23 | let depot = utils::read_depot(&config.archive_path)?; | ||
| 24 | |||
| 25 | for link in utils::collect_links_by_base_paths(&depot, &opts.paths) { | ||
| 26 | log::info!("Uninstalling link : {}", link); | ||
| 27 | depot.uninstall_link(link, &install_base)?; | ||
| 28 | } | ||
| 29 | |||
| 30 | Ok(()) | ||
| 31 | } | ||
