From 7633bdf8782d4115eb6b26c3c44ea1be9a6fd629 Mon Sep 17 00:00:00 2001 From: Penguin Date: Tue, 21 Dec 2021 20:35:43 -0600 Subject: [PATCH] real progress is new is now incomplete, but many of the lower level functions are working. i just need the project to get to the 'push' checkpoint and i can test everything --- igloo_core/src/igloo_action.rs | 41 ++++++++++++++++++++++ igloo_core/src/igloo_manifest.rs | 1 - igloo_core/src/igloo_project.rs | 6 ++-- igloo_core/src/lib.rs | 59 ++++++++++++++++++++++++-------- 4 files changed, 89 insertions(+), 18 deletions(-) diff --git a/igloo_core/src/igloo_action.rs b/igloo_core/src/igloo_action.rs index 9c12de2..aeb0bde 100644 --- a/igloo_core/src/igloo_action.rs +++ b/igloo_core/src/igloo_action.rs @@ -5,6 +5,9 @@ use crate::IglooType::*; use crate::IglooStatus; use crate::IglooStatus::*; +use crate::Igloo; +use crate::igloo_project::IglooProject; + pub fn igloo_subcommand(args: &ArgMatches) -> Result { let mut _res_type: IglooType = IT_NULL; @@ -61,3 +64,41 @@ pub fn igloo_subcommand(args: &ArgMatches) -> Result Ok(_res_type) } + +pub fn ia_new(igloo: &Igloo, project_name: String, initial_target: String) -> IglooStatus +{ + let mut ret: IglooStatus = IS_GOOD; + + // is igloo project + if IglooProject::is_igloo_prj(&igloo.env.cwd) + { + println!("Calling igloo new from inside igloo project..."); + ret = IS_BAD; + return ret + } + + // check if project folder already exists + if std::path::Path::new( + &igloo.env.cwd.join(&project_name)).exists() + { + ret = IS_BAD; + return ret + } + + let created_project = match IglooProject::from_new(igloo, project_name) + { + Ok(v) => v, + Err(e) => + { + println!("{:?}", e); + panic!(); + } + }; + + // Now populate + // created_project.populate() + + + + ret +} diff --git a/igloo_core/src/igloo_manifest.rs b/igloo_core/src/igloo_manifest.rs index dc6b794..0c25c70 100644 --- a/igloo_core/src/igloo_manifest.rs +++ b/igloo_core/src/igloo_manifest.rs @@ -56,4 +56,3 @@ impl IglooProjectManifest } } - diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index d0c50ba..f4ac746 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -32,9 +32,9 @@ impl<'a> IglooProject<'a> /// This means we do not yet have any project in storage /// and we must generate those directories, files, and symlinks /// and then populate the project in memory - pub fn from_new(igloo_in: &'a Igloo, project_name: String) -> IglooProject + pub fn from_new(igloo_in: &'a Igloo, project_name: String) -> Result { - IglooProject + Ok(IglooProject { name: ich_new_get_project_name(igloo_in), /// targets -- a vector of targets added for this project @@ -43,7 +43,7 @@ impl<'a> IglooProject<'a> - } + }) } /// Used to populate an IglooProject from an existing project diff --git a/igloo_core/src/lib.rs b/igloo_core/src/lib.rs index f65e1b3..307b8c4 100644 --- a/igloo_core/src/lib.rs +++ b/igloo_core/src/lib.rs @@ -62,8 +62,6 @@ use IglooType::*; pub struct Igloo { cli_info: IglooCliInfo, - // manifest containing all mcu information - master_target_manifest: Config, env: IglooEnv, } @@ -73,7 +71,6 @@ impl Igloo { Igloo { - master_target_manifest: Config::new(), cli_info: IglooCliInfo::new(), env: IglooEnv::get_env(), } @@ -83,16 +80,6 @@ impl Igloo { let mut res: IglooType = IT_NULL; - // let master_target_manifest = match igloo_manifest::get_master_target_manifest(self) - // { - // IS_GOOD => , - // e => - // { - // println!("{:?}", e); - // return Err(e) - // }, - // } - // Assign instance type (new, run, push, etc) igloo_action::igloo_subcommand(&self.cli_info.raw) } @@ -100,8 +87,52 @@ impl Igloo pub fn run(&self, inst_type: IglooType) -> IglooStatus { let mut res_err = IS_GOOD; - let mut prj: IglooProject; + match inst_type + { + IT_NEW => + { + return igloo_action::ia_new(self, + igloo_cli::ich_new_get_project_name(self), + igloo_cli::ich_new_get_target_name(self)) + } + IT_RUN => + { + + } + IT_PUSH => + { + + } + IT_PULL => + { + + } + IT_HELP => + { + + } + IT_BUILD => + { + + } + IT_ERASE => + { + + } + IT_INFO => + { + + } + IT_TARGET => + { + + } + IT_NULL => + { + + } + } res_err } }