From b7c98af8fdec5f2db260e66e421ed7e8b5a81acc Mon Sep 17 00:00:00 2001 From: Kalyan Mudumby <71078441+theinhumaneme@users.noreply.github.com> Date: Thu, 10 Oct 2024 13:36:33 +0530 Subject: [PATCH] fix double banner print isolated the banner printing as the init() was invoked twice --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 2fb8430..9ed4334 100644 --- a/src/main.rs +++ b/src/main.rs @@ -23,7 +23,7 @@ use objects::structs::{GlobalConfiguration, ProjectConfiguation}; // else use the docker bindings or the os to operate using the files generated // -fn init() -> String { +fn init() -> GlobalConfiguration { let global_configuration_file = "global.toml"; let global_configuration = match fs::read_to_string(global_configuration_file) { Ok(c) => { @@ -45,6 +45,9 @@ fn init() -> String { exit(1); } }; + config +} +fn banner(config: GlobalConfiguration) { let print_banner: bool = config.print_banner; if print_banner { match to_art("AUTO DEPLOY".to_string(), "default", 0, 0, 0) { @@ -64,18 +67,18 @@ fn init() -> String { if config.client.is_some() { print!("\nClient: {}", config.client.unwrap()); } - println!("\n"); // standard gutter - config.configuration_file + println!("\n"); } fn main() { dotenv().ok(); let git_username = std::env::var("GIT_USERNAME").expect("GIT_USERNAME must be set."); let git_password: String = std::env::var("GIT_PASSWORD").expect("GIT_PASSWORD must be set."); - if !check_file(init()) { + if !check_file(init().configuration_file) { eprintln!("Could not read project configuration file"); exit(1); } - let configuration_file = fs::read_to_string(init()).unwrap(); + banner(init()); + let configuration_file = fs::read_to_string(init().configuration_file).unwrap(); let config: ProjectConfiguation = match toml::from_str(&configuration_file) { Ok(d) => d, Err(_) => {