|
|
@ -9,11 +9,84 @@ use crate::IglooStatus::*;
|
|
|
|
|
|
|
|
|
|
|
|
use crate::igloo_target::IglooTarget;
|
|
|
|
use crate::igloo_target::IglooTarget;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use serde::{Serialize, Deserialize};
|
|
|
|
|
|
|
|
use config::Config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
|
|
|
|
pub struct Settings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
testvar: String,
|
|
|
|
|
|
|
|
profile: Profile,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Basic profile settings
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
|
|
|
|
|
|
struct Profile
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: String,
|
|
|
|
|
|
|
|
targets: Vec::<String>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Profile
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fn default() -> Profile
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Profile
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
name: String::new(),
|
|
|
|
|
|
|
|
targets: Vec::new(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
impl Settings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
pub fn default() -> Settings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Settings
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
testvar: String::new(),
|
|
|
|
|
|
|
|
profile: Profile::default(),
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn from_project_file(self, igloo: &Igloo) -> Result<Settings, IglooStatus>
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let mut config = config::Config::default();
|
|
|
|
|
|
|
|
config.merge(
|
|
|
|
|
|
|
|
config::File::with_name(
|
|
|
|
|
|
|
|
igloo.env
|
|
|
|
|
|
|
|
.cwd
|
|
|
|
|
|
|
|
.clone()
|
|
|
|
|
|
|
|
.join("test")
|
|
|
|
|
|
|
|
.join("igloo.toml")
|
|
|
|
|
|
|
|
.to_str().unwrap())).unwrap();
|
|
|
|
|
|
|
|
let x = config.try_into::<Settings>().unwrap();
|
|
|
|
|
|
|
|
println!("{:?}", x);
|
|
|
|
|
|
|
|
Ok(x)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn to_project_file(self, igloo: &Igloo) -> IglooStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IglooStatus::IS_GOOD
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn set_profile_name(&mut self, name: String)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
self.profile.name = name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn add_target(&mut self, target_name: String)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
self.profile.targets.push(target_name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub struct IglooProject<'a>
|
|
|
|
pub struct IglooProject<'a>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
igloo: &'a Igloo,
|
|
|
|
igloo: &'a Igloo,
|
|
|
|
name: String,
|
|
|
|
config: Settings,
|
|
|
|
targets: Vec<IglooTarget>,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl<'a> IglooProject<'a>
|
|
|
|
impl<'a> IglooProject<'a>
|
|
|
@ -23,36 +96,33 @@ impl<'a> IglooProject<'a>
|
|
|
|
IglooProject
|
|
|
|
IglooProject
|
|
|
|
{
|
|
|
|
{
|
|
|
|
igloo: igloo_in,
|
|
|
|
igloo: igloo_in,
|
|
|
|
name: String::new(),
|
|
|
|
config: Settings::default(),
|
|
|
|
targets: Vec::default(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// Used to populate an IglooProject from scratch
|
|
|
|
/// Used to populate an IglooProject from scratch
|
|
|
|
/// This means we do not yet have any project in storage
|
|
|
|
/// This takes input from cli and generates the project in memory
|
|
|
|
/// 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) -> Result<IglooProject, IglooStatus>
|
|
|
|
pub fn from_new(igloo_in: &'a Igloo, project_name: String) -> Result<IglooProject, IglooStatus>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
let mut settings = Settings::default();
|
|
|
|
|
|
|
|
settings.set_profile_name(project_name);
|
|
|
|
Ok(IglooProject
|
|
|
|
Ok(IglooProject
|
|
|
|
{
|
|
|
|
{
|
|
|
|
name: ich_new_get_project_name(igloo_in),
|
|
|
|
|
|
|
|
/// targets -- a vector of targets added for this project
|
|
|
|
|
|
|
|
targets: Vec::default(),
|
|
|
|
|
|
|
|
igloo: igloo_in,
|
|
|
|
igloo: igloo_in,
|
|
|
|
|
|
|
|
config: settings,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Used to populate an IglooProject from an existing project
|
|
|
|
/// Used to create an IglooProject from an existing project
|
|
|
|
/// So this will be called when things like
|
|
|
|
/// So this will be called when things like
|
|
|
|
/// igloo run, push, pull, erase, etc... are called
|
|
|
|
/// igloo run, push, pull, erase, etc... are called
|
|
|
|
pub fn from_existing(igloo: &'a Igloo) -> IglooProject
|
|
|
|
pub fn from_existing(igloo_in: &'a Igloo) -> Result<IglooProject, IglooStatus>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IglooProject::default(igloo)
|
|
|
|
Ok(IglooProject
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
igloo: igloo_in,
|
|
|
|
|
|
|
|
config: Settings::default().from_project_file(igloo_in).unwrap(),
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool
|
|
|
|
pub fn is_igloo_prj(path: &std::path::PathBuf) -> bool
|
|
|
@ -68,4 +138,18 @@ impl<'a> IglooProject<'a>
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// creates project files
|
|
|
|
|
|
|
|
/// including igloo.toml
|
|
|
|
|
|
|
|
pub fn generate(self) -> IglooStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
IglooStatus::IS_GOOD
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn add_target(&mut self, target: String) -> IglooStatus
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
let mut ret = IS_GOOD;
|
|
|
|
|
|
|
|
self.config.add_target(target);
|
|
|
|
|
|
|
|
ret
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|