aboutsummaryrefslogtreecommitdiff
path: root/dotup_cli/src/commands/install.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dotup_cli/src/commands/install.rs')
-rw-r--r--dotup_cli/src/commands/install.rs11
1 files changed, 1 insertions, 10 deletions
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::*;
8/// If a file or directory already exists at the location a link would be installed this command will fail. 8/// If a file or directory already exists at the location a link would be installed this command will fail.
9#[derive(Parser)] 9#[derive(Parser)]
10pub struct Opts { 10pub struct Opts {
11 /// The location where links will be installed to.
12 /// Defaults to the home directory.
13 #[clap(long)]
14 install_base: Option<PathBuf>,
15
16 /// The files/directories to install. 11 /// The files/directories to install.
17 #[clap(min_values = 1, default_value = ".")] 12 #[clap(min_values = 1, default_value = ".")]
18 paths: Vec<PathBuf>, 13 paths: Vec<PathBuf>,
19} 14}
20 15
21pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { 16pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> {
22 let install_base = match opts.install_base {
23 Some(path) => path,
24 None => utils::home_directory()?,
25 };
26 let depot = utils::read_depot(&config.archive_path)?; 17 let depot = utils::read_depot(&config.archive_path)?;
27 18
28 for link in utils::collect_links_by_base_paths(&depot, &opts.paths) { 19 for link in utils::collect_links_by_base_paths(&depot, &opts.paths) {
29 log::info!("Installing link {}", link); 20 log::info!("Installing link {}", link);
30 depot.install_link(link, &install_base)?; 21 depot.install_link(link, &config.install_path)?;
31 } 22 }
32 23
33 Ok(()) 24 Ok(())