aboutsummaryrefslogtreecommitdiff
path: root/dotup_cli/src/commands/install.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-07-08 17:11:46 -0400
committerdiogo464 <[email protected]>2021-07-08 17:11:46 -0400
commited0baec0a3f953c99445f6842dadc5566e89cb75 (patch)
tree9f988c41db34907283dd126dc57d29b3d0792bd9 /dotup_cli/src/commands/install.rs
Initial commit
Diffstat (limited to 'dotup_cli/src/commands/install.rs')
-rw-r--r--dotup_cli/src/commands/install.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/dotup_cli/src/commands/install.rs b/dotup_cli/src/commands/install.rs
new file mode 100644
index 0000000..72cabf3
--- /dev/null
+++ b/dotup_cli/src/commands/install.rs
@@ -0,0 +1,31 @@
1use clap::Clap;
2use std::path::PathBuf;
3
4use super::prelude::*;
5
6#[derive(Clap)]
7pub struct Opts {
8 /// The location where links will be installed to.
9 /// Defaults to home directory.
10 #[clap(long)]
11 install_base: Option<PathBuf>,
12
13 /// The files/directories to install
14 #[clap(required = true, min_values = 1)]
15 paths: Vec<PathBuf>,
16}
17
18pub 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!("Installing link {}", link);
27 depot.install_link(link, &install_base)?;
28 }
29
30 Ok(())
31}