diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/download.rs | 4 | ||||
-rw-r--r-- | src/main.rs | 4 |
2 files changed, 8 insertions, 0 deletions
diff --git a/src/download.rs b/src/download.rs index 72cdaf3..82bb302 100644 --- a/src/download.rs +++ b/src/download.rs @@ -14,6 +14,8 @@ use super::Args; type HttpsClient = Client<HttpsConnector<HttpConnector>>; pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> { + let output_file_dir = &args.directory_prefix; + let output_file_path = if let Some(output) = &args.output_document { Some(output.clone()) } else { @@ -49,6 +51,8 @@ pub(crate) async fn download(url: Uri, args: &Args) -> Result<(), Error> { PathBuf::from(format!("index{}", extension)) }; + let output_file_path = output_file_dir.join(output_file_path); + let mut output_file = fs::File::create(output_file_path).await?; while let Some(data) = response.body_mut().data().await { diff --git a/src/main.rs b/src/main.rs index 28de762..a622afd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,10 @@ struct Args { #[structopt(short = "O", long)] output_document: Option<PathBuf>, + /// Set output directory + #[structopt(short = "P", long, default_value = ".")] + directory_prefix: PathBuf, + /// The URLs to download urls: Vec<Uri>, } |