diff options
Diffstat (limited to 'dotup_cli/src/main.rs')
| -rw-r--r-- | dotup_cli/src/main.rs | 18 |
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 | ||
| 14 | use clap::{AppSettings, Clap}; | 14 | use clap::{AppSettings, Clap}; |
| 15 | use commands::utils; | ||
| 15 | use flexi_logger::Logger; | 16 | use flexi_logger::Logger; |
| 16 | use std::{ | 17 | use std::{ |
| 17 | collections::HashMap, | 18 | collections::HashMap, |
| @@ -21,14 +22,15 @@ use std::{ | |||
| 21 | 22 | ||
| 22 | use prelude::*; | 23 | use prelude::*; |
| 23 | 24 | ||
| 24 | const DEFAULT_DEPOT_NAME: &str = "depot.toml"; | ||
| 25 | |||
| 26 | #[derive(Clap)] | 25 | #[derive(Clap)] |
| 27 | #[clap(setting = AppSettings::ColoredHelp)] | 26 | #[clap(setting = AppSettings::ColoredHelp)] |
| 28 | struct Opts { | 27 | struct 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), |
