From f74f64f7b44a14ea9ee5944dc47b8d1d0d9f1553 Mon Sep 17 00:00:00 2001 From: Penguin Date: Sun, 19 Dec 2021 02:02:18 -0600 Subject: [PATCH] working on implementing run, rewriting IglooProject and IglooTarget so they make more sense. also implementing cli info helper functions instead of bulk pasting code everywhere --- igloo_core/src/igloo_cli.rs | 26 ++++++++++++++ igloo_core/src/igloo_project.rs | 60 +++++++++++++++++++++++++++++++-- igloo_core/src/igloo_target.rs | 20 +++++++++++ 3 files changed, 103 insertions(+), 3 deletions(-) diff --git a/igloo_core/src/igloo_cli.rs b/igloo_core/src/igloo_cli.rs index ffdb0c5..84317df 100644 --- a/igloo_core/src/igloo_cli.rs +++ b/igloo_core/src/igloo_cli.rs @@ -1,5 +1,6 @@ use clap::{App, Arg, ArgMatches}; +use crate::Igloo; use crate::IglooType; use crate::IglooType::*; use crate::IglooStatus; @@ -101,3 +102,28 @@ fn igloo_run_cli() -> clap::ArgMatches .get_matches(); ret_app } + +/// Igloo CLI Helper functions +/// These functions take some raw cli input and give us some helpful values +/// Putting these here so I don't have to pollute other code with this +pub fn ich_new_get_project_name(igloo: &Igloo) -> String +{ + return String::from(igloo + .cli_info + .raw + .subcommand() + .unwrap().1 + .value_of("project_name") + .unwrap()) +} + +pub fn ich_new_get_target_name(igloo: &Igloo) -> String +{ + return String::from(igloo + .cli_info + .raw + .subcommand() + .unwrap().1 + .value_of("target") + .unwrap()) +} diff --git a/igloo_core/src/igloo_project.rs b/igloo_core/src/igloo_project.rs index 282eeb7..12cd444 100644 --- a/igloo_core/src/igloo_project.rs +++ b/igloo_core/src/igloo_project.rs @@ -1,9 +1,63 @@ -pub struct IglooProject -{ +use crate::Igloo; +use crate::igloo_cli::*; + +use crate::IglooType; +use crate::IglooType::*; + +use crate::IglooStatus; +use crate::IglooStatus::*; +use crate::igloo_target::IglooTarget; + +pub struct IglooProject<'a> +{ + igloo: &'a Igloo, + name: String, + targets: Vec, } -impl IglooProject +impl<'a> IglooProject<'a> { + /// Used to populate an IglooProject from scratch + /// 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 + { + IglooProject + { + name: ich_new_get_project_name(igloo_in), + /// targets -- a vector of targets added for this project + targets: Vec::default(), + igloo: igloo_in, + + + + } + } + + /// Used to populate an IglooProject from an existing project + /// So this will be called when things like + /// igloo run, push, pull, erase, etc... are called + pub fn from_existing(igloo: &'a Igloo) -> IglooProject + { + IglooProject + { + name: + } + } + + pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool + { + if !path.join("igloo").exists() + { + return false + } + if !path.join("igloo.toml").exists() + { + return false + } + return true + } } diff --git a/igloo_core/src/igloo_target.rs b/igloo_core/src/igloo_target.rs index e69de29..5147cf2 100644 --- a/igloo_core/src/igloo_target.rs +++ b/igloo_core/src/igloo_target.rs @@ -0,0 +1,20 @@ +struct IglooTargetLinks +{ + common: String, + mcu: String, + ld: String, + cfg: String, +} + +pub struct IglooTarget +{ + name: String, + links: IglooTargetLinks, + includes: Vec, + scripts: Vec, +} + +impl IglooTarget +{ + +}