aboutsummaryrefslogtreecommitdiff
path: root/dotup_cli/src/main.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2021-12-24 21:09:44 +0000
committerdiogo464 <[email protected]>2021-12-24 21:09:44 +0000
commit6817631ddee3795af3a558bf38e477da4ae5b1cb (patch)
tree96b54bc5fcef87046e065726574a473e10989124 /dotup_cli/src/main.rs
parentffcb43df8f39a55be468cf4bdfecd72dd026d940 (diff)
made install-path a global option
Diffstat (limited to 'dotup_cli/src/main.rs')
-rw-r--r--dotup_cli/src/main.rs14
1 files changed, 13 insertions, 1 deletions
diff --git a/dotup_cli/src/main.rs b/dotup_cli/src/main.rs
index 05fa850..6161ca7 100644
--- a/dotup_cli/src/main.rs
+++ b/dotup_cli/src/main.rs
@@ -45,6 +45,11 @@ struct Opts {
45 #[clap(short, long, parse(from_occurrences))] 45 #[clap(short, long, parse(from_occurrences))]
46 verbose: i32, 46 verbose: i32,
47 47
48 /// The location where links will be installed to.
49 /// Defaults to the home directory.
50 #[clap(short, long)]
51 install_path: Option<PathBuf>,
52
48 #[clap(subcommand)] 53 #[clap(subcommand)]
49 subcmd: SubCommand, 54 subcmd: SubCommand,
50} 55}
@@ -80,9 +85,16 @@ fn main() -> anyhow::Result<()> {
80 Some(path) => path, 85 Some(path) => path,
81 None => utils::find_archive_path()?, 86 None => utils::find_archive_path()?,
82 }; 87 };
88 let install_path = match opts.install_path {
89 Some(path) => path,
90 None => utils::home_directory()?,
91 };
83 log::debug!("Archive path : {}", archive_path.display()); 92 log::debug!("Archive path : {}", archive_path.display());
84 93
85 let config = Config { archive_path }; 94 let config = Config {
95 archive_path,
96 install_path,
97 };
86 98
87 match opts.subcmd { 99 match opts.subcmd {
88 SubCommand::Init(opts) => commands::init::main(config, opts), 100 SubCommand::Init(opts) => commands::init::main(config, opts),