From 92b05a877eb772985d2f4fc9cd198ca642b69b6a Mon Sep 17 00:00:00 2001 From: diogo464 Date: Tue, 8 Feb 2022 09:21:12 +0000 Subject: removed old code --- dotup_cli/src/commands/mv.rs | 53 -------------------------------------------- 1 file changed, 53 deletions(-) delete mode 100644 dotup_cli/src/commands/mv.rs (limited to 'dotup_cli/src/commands/mv.rs') diff --git a/dotup_cli/src/commands/mv.rs b/dotup_cli/src/commands/mv.rs deleted file mode 100644 index aae2715..0000000 --- a/dotup_cli/src/commands/mv.rs +++ /dev/null @@ -1,53 +0,0 @@ -use std::path::{Path, PathBuf}; - -use super::prelude::*; - -/// Install links. (Creates symlinks). -/// -/// Installing a link will create the necessary directories. -/// 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 files/directories to move - #[clap(min_values = 2)] - paths: Vec, -} - -pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { - let mut depot = utils::read_depot(&config.archive_path)?; - - let (sources, destination) = match opts.paths.as_slice() { - [source, destination] => {} - [sources @ .., destination] => { - let mut curr_destination = destination.to_owned(); - for source in sources { - let filename = match source.file_name() { - Some(filename) => filename, - None => { - log::warn!("Ignoring '{}', unknown file name", source.display()); - continue; - } - }; - curr_destination.push(filename); - std::fs::rename(source, &curr_destination)?; - if let Some(id) = depot.get_link_id_by_path(&source) { - depot.rename_link(id, &curr_destination); - } - curr_destination.pop(); - } - } - _ => unreachable!(), - }; - - utils::write_depot(&depot)?; - - Ok(()) -} - -fn rename(depot: &mut Depot, source: &Path, destination: &Path) -> anyhow::Result<()> { - std::fs::rename(source, &destination)?; - if let Some(id) = depot.get_link_id_by_path(&source) { - depot.rename_link(id, &destination); - } - Ok(()) -} -- cgit