From 13c006038e418ffe6673d952f79be08b8af6eb01 Mon Sep 17 00:00:00 2001 From: Penguin Date: Thu, 23 Dec 2021 20:02:28 -0600 Subject: [PATCH] right now im treating nearly every issue as an error when debug logging. later i can revisit this and classify severity with respect to the actual error being thrown --- igloo_core/src/.#igloo_action.rs | 1 + igloo_core/src/igloo_action.rs | 38 ++++++++++++++++++++++++++------ igloo_core/src/igloo_project.rs | 16 +++++++------- igloo_core/src/lib.rs | 12 +++++----- 4 files changed, 47 insertions(+), 20 deletions(-) create mode 120000 igloo_core/src/.#igloo_action.rs diff --git a/igloo_core/src/.#igloo_action.rs b/igloo_core/src/.#igloo_action.rs new file mode 120000 index 0000000..10026a8 --- /dev/null +++ b/igloo_core/src/.#igloo_action.rs @@ -0,0 +1 @@ +penguin@gpenguin.2954:1640039390 \ No newline at end of file diff --git a/igloo_core/src/igloo_action.rs b/igloo_core/src/igloo_action.rs index eb76054..e285d8b 100644 --- a/igloo_core/src/igloo_action.rs +++ b/igloo_core/src/igloo_action.rs @@ -78,8 +78,8 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig // is igloo project if IglooProject::is_igloo_prj(&igloo.env.cwd) { - println!("Calling igloo new from inside igloo project..."); - ret = IS_BAD; + ret = IS_NEW_CALLED_IN_EXISTING_PRJ; + igloo_debug!(WARNING, ret); return ret } @@ -87,7 +87,8 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig if std::path::Path::new( &igloo.env.cwd.join(&project_name)).exists() { - ret = IS_BAD; + ret = IS_NEW_DIR_ALREADY_EXISTS; + igloo_debug!(WARNING, ret); return ret } @@ -96,15 +97,38 @@ pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> Ig Ok(v) => v, Err(e) => { - println!("{:?}", e); - panic!(); + igloo_debug!(ERROR, e); + return e } }; - prj.add_target_to_config(initial_target); + ret = prj.add_target_to_config(initial_target); + if ret != IS_GOOD + { + igloo_debug!(ERROR, ret); + return ret + } // Now populate - prj.generate(); + ret = prj.generate(); + if ret != IS_GOOD + { + igloo_debug!(ERROR, ret); + return ret + } + + ret = prj.generate_igloo_header(); + if ret != IS_GOOD + { + igloo_debug!(ERROR, ret); + return ret + } + + ret = prj.generate_igloo_main(); + if ret != IS_GOOD + { + igloo_debug!(ERROR, ret); + } diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index 5947b23..bda60f1 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -1,12 +1,11 @@ use crate::Igloo; use crate::igloo_cli::*; -use crate::IglooType; -use crate::IglooType::*; - -use crate::IglooStatus; -use crate::IglooStatus::*; +use crate::IglooType::{self, *}; +use crate::IglooStatus::{self, *}; +use crate::IglooDebugSeverity::{self, *}; +use crate::igloo_util::*; use crate::igloo_project; use crate::igloo_target::IglooTarget; @@ -117,6 +116,7 @@ impl<'a> IglooProject<'a> /// This takes input from cli and generates the project in memory pub fn from_new(igloo_in: &'a Igloo, project_name: String) -> Result { + igloo_debug!(TRACE, IS_NONE, "Creating new igloo project named {}", project_name); let mut settings = Settings::default(); settings.profile.name = String::from(&project_name); Ok(IglooProject @@ -263,12 +263,12 @@ impl<'a> IglooProject<'a> IS_GOOD } - fn generate_igloo_header(&self) -> IglooStatus + pub fn generate_igloo_header(&self) -> IglooStatus { - IS_GOOD + IS_BAD } - fn generate_igloo_main(&self) -> IglooStatus + pub fn generate_igloo_main(&self) -> IglooStatus { IS_GOOD } diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index b7ce9d6..ee16eff 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -53,11 +53,13 @@ pub enum IglooDebugSeverity #[derive(PartialEq)] pub enum IglooStatus { - IS_GOOD = 0x00, - IS_BAD = 0x01, - IS_UNKNOWN = 0x02, - IS_FAILED_TO_LOAD_MTM = 0x03, - IS_NONE = 0xFF, + IS_GOOD = 0x00, + IS_BAD = 0x01, + IS_UNKNOWN = 0x02, + IS_FAILED_TO_LOAD_MTM = 0x03, + IS_NEW_CALLED_IN_EXISTING_PRJ = 0x04, + IS_NEW_DIR_ALREADY_EXISTS = 0x05, + IS_NONE = 0xFF, } use IglooStatus::*;