diff options
Diffstat (limited to 'dotup_cli/src/commands/unlink.rs')
| -rw-r--r-- | dotup_cli/src/commands/unlink.rs | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/dotup_cli/src/commands/unlink.rs b/dotup_cli/src/commands/unlink.rs deleted file mode 100644 index abe23e3..0000000 --- a/dotup_cli/src/commands/unlink.rs +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | use std::{ | ||
| 2 | fs::{DirEntry, Metadata}, | ||
| 3 | path::{Path, PathBuf}, | ||
| 4 | }; | ||
| 5 | |||
| 6 | use super::prelude::*; | ||
| 7 | |||
| 8 | /// Unlinks files/directories. | ||
| 9 | /// | ||
| 10 | /// This will recursively remove links. If a path is a directory then it will remove all links | ||
| 11 | /// recursively. | ||
| 12 | /// The links are not uninstall by default, see the --uninstall parameter. | ||
| 13 | #[derive(Parser)] | ||
| 14 | pub struct Opts { | ||
| 15 | /// Specify the install base if the links are also to be uninstalled. | ||
| 16 | #[clap(long)] | ||
| 17 | uninstall: Option<PathBuf>, | ||
| 18 | |||
| 19 | /// The paths to unlink. | ||
| 20 | #[clap(required = true, min_values = 1)] | ||
| 21 | paths: Vec<PathBuf>, | ||
| 22 | } | ||
| 23 | |||
| 24 | pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { | ||
| 25 | let mut depot = utils::read_depot(&config.archive_path)?; | ||
| 26 | |||
| 27 | for link_id in utils::collect_link_ids_by_base_paths(&depot, &opts.paths) { | ||
| 28 | let link = depot.get_link(link_id).unwrap(); | ||
| 29 | log::info!( | ||
| 30 | "Unlinking(uninstall = {}) : {}", | ||
| 31 | opts.uninstall.is_some(), | ||
| 32 | link | ||
| 33 | ); | ||
| 34 | if let Some(ref install_base) = opts.uninstall { | ||
| 35 | depot.uninstall_link(link, &install_base)?; | ||
| 36 | } | ||
| 37 | depot.remove_link(link_id); | ||
| 38 | } | ||
| 39 | |||
| 40 | utils::write_depot(&depot)?; | ||
| 41 | |||
| 42 | Ok(()) | ||
| 43 | } | ||
