diff options
| author | diogo464 <[email protected]> | 2021-12-24 21:09:44 +0000 |
|---|---|---|
| committer | diogo464 <[email protected]> | 2021-12-24 21:09:44 +0000 |
| commit | 6817631ddee3795af3a558bf38e477da4ae5b1cb (patch) | |
| tree | 96b54bc5fcef87046e065726574a473e10989124 /dotup_cli/src/commands/install.rs | |
| parent | ffcb43df8f39a55be468cf4bdfecd72dd026d940 (diff) | |
made install-path a global option
Diffstat (limited to 'dotup_cli/src/commands/install.rs')
| -rw-r--r-- | dotup_cli/src/commands/install.rs | 11 |
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)] |
| 10 | pub struct Opts { | 10 | pub 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 | ||
| 21 | pub fn main(config: Config, opts: Opts) -> anyhow::Result<()> { | 16 | pub 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(()) |
