From 56c7d9a5213a76f5ca820995b2cbe37bbc94edc5 Mon Sep 17 00:00:00 2001 From: Marvin Beckers Date: Mon, 20 Nov 2023 19:36:27 +0100 Subject: [PATCH 1/2] cmd: create configuration directory if it does not exist Signed-off-by: Marvin Beckers --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ffdb4cf..a125d3c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,13 +6,25 @@ mod kubeconfig; use env_logger::Builder; use log::{self, SetLoggerError}; use std::error::Error; +use std::fs; +use std::process; fn main() -> Result<(), Box> { let matches = cmd::cli().get_matches(); let config_path = config::get_config_path()?; setup_logger(matches.get_flag("verbose"))?; - log::debug!("using {} as config path", config_path.display()); + log::debug!("using {} as configuration directory", config_path.display()); + + if !config_path.is_dir() { + log::debug!("creating configuration directory as it does not exist"); + fs::create_dir_all(&config_path).or_else( + |err: std::io::Error| -> Result<(), Box> { + log::error!("failed to create directory: {err}"); + process::exit(1); + }, + )?; + } cmd::execute(&config_path, matches.subcommand()) } From 08deb262b02be5df3c367a2688d8b01ee7142532 Mon Sep 17 00:00:00 2001 From: Marvin Beckers Date: Mon, 20 Nov 2023 19:38:23 +0100 Subject: [PATCH 2/2] cargo: bump version to v0.1.1 Signed-off-by: Marvin Beckers --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f761c07..79fcde0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -782,7 +782,7 @@ dependencies = [ [[package]] name = "kubeconfig-bikeshed" -version = "0.1.0" +version = "0.1.1" dependencies = [ "clap", "clap_complete", diff --git a/Cargo.toml b/Cargo.toml index a393b43..4556ee4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "kubeconfig-bikeshed" -version = "0.1.0" +version = "0.1.1" edition = "2021" authors = ["Marvin Beckers "]