From 08d4e1b94cf564ff3c3ffc3eb1d5d460cf828a49 Mon Sep 17 00:00:00 2001 From: J / Jacob Babich Date: Mon, 30 Sep 2024 02:29:58 -0400 Subject: [PATCH] feat!: this is the correct way to format a breaking change unlike my previous commit - ensure the application data directory, and the tracing directory within it, exists this is a BREAKING CHANGE because the application will now crash if either directory cannot be created due to some I/O / filesystem error --- multibinary/src/main.rs | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/multibinary/src/main.rs b/multibinary/src/main.rs index 6442fc6..fc747f1 100644 --- a/multibinary/src/main.rs +++ b/multibinary/src/main.rs @@ -1,4 +1,4 @@ -use std::path::PathBuf; +use std::{fs::create_dir_all, io::ErrorKind, path::PathBuf}; use clap::Parser; @@ -13,7 +13,27 @@ struct Args { } fn main() { - let args = Args::parse(); + let Args { + application_data_directory, + } = Args::parse(); + + match create_dir_all(&application_data_directory) { + Ok(()) => {} + Err(e) if e.kind() == ErrorKind::AlreadyExists => {} + Err(e) => { + panic!("{}", e); + } + } + + let tracing_directory = application_data_directory.join("logs"); + + match create_dir_all(&tracing_directory) { + Ok(()) => {} + Err(e) if e.kind() == ErrorKind::AlreadyExists => {} + Err(e) => { + panic!("{}", e); + } + } #[cfg(feature = "cli-clap")] ac_qu_ai_nt_cli_clap::main();