aboutsummaryrefslogtreecommitdiff
path: root/dotup_cli/src/main.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-07-09 10:03:42 -0400
committerdiogo464 <[email protected]>2021-07-09 10:03:42 -0400
commit21c234735ebf74899ce9a98cb46d9500b3f51e89 (patch)
tree6f0f5c5033bc014813ac2b391616f8e7cff35a9c /dotup_cli/src/main.rs
parent3469dd5ab5b475a96f852b8c2e12a0b2c1c09caf (diff)
Search parent directories for depot file.
If the depot file is not specified and is not found in the current directory then it will be searched trough the parent directories until a depot file is found.
Diffstat (limited to 'dotup_cli/src/main.rs')
-rw-r--r--dotup_cli/src/main.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/dotup_cli/src/main.rs b/dotup_cli/src/main.rs
index 867afb4..0b4bff1 100644
--- a/dotup_cli/src/main.rs
+++ b/dotup_cli/src/main.rs
@@ -12,6 +12,7 @@ pub mod prelude {
12} 12}
13 13
14use clap::{AppSettings, Clap}; 14use clap::{AppSettings, Clap};
15use commands::utils;
15use flexi_logger::Logger; 16use flexi_logger::Logger;
16use std::{ 17use std::{
17 collections::HashMap, 18 collections::HashMap,
@@ -21,14 +22,15 @@ use std::{
21 22
22use prelude::*; 23use prelude::*;
23 24
24const DEFAULT_DEPOT_NAME: &str = "depot.toml";
25
26#[derive(Clap)] 25#[derive(Clap)]
27#[clap(setting = AppSettings::ColoredHelp)] 26#[clap(setting = AppSettings::ColoredHelp)]
28struct Opts { 27struct Opts {
29 /// Path to the depot file. 28 /// Path to the depot file.
30 #[clap(long, default_value = DEFAULT_DEPOT_NAME)] 29 ///
31 depot: PathBuf, 30 /// By default it will try to find a file named "depot.toml" in the current directory or any of
31 /// the parent directories.
32 #[clap(long)]
33 depot: Option<PathBuf>,
32 34
33 /// Disable output to the console 35 /// Disable output to the console
34 #[clap(short, long)] 36 #[clap(short, long)]
@@ -76,9 +78,13 @@ fn main() -> anyhow::Result<()> {
76 .start()?; 78 .start()?;
77 } 79 }
78 80
79 let config = Config { 81 let archive_path = match opts.depot {
80 archive_path: opts.depot, 82 Some(path) => path,
83 None => utils::find_archive_path()?,
81 }; 84 };
85 log::debug!("Archive path : {}", archive_path.display());
86
87 let config = Config { archive_path };
82 88
83 match opts.subcmd { 89 match opts.subcmd {
84 SubCommand::Init(opts) => commands::init::main(config, opts), 90 SubCommand::Init(opts) => commands::init::main(config, opts),