Project creation works mostly. just need symlinks and initial file spawns

unstable
penguin 4 years ago
parent e8b0dfae03
commit e646a85c5e

@ -1 +1,50 @@
q
break main
r
n
r
n
q
break igloo_manifest.rs:15
r
s
s
n
n
n
n
n
n
n
n
n
n
n
n
n
q
break igloo_manifest.rs:15
r
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
n
q

@ -28,10 +28,13 @@ pub enum IglooErrType
IGLOO_INVALID_PROJECT_NAME = 7,
IGLOO_ENV_INFO_INVALID = 8,
IGLOO_INVALID_TARGET = 9,
IGLOO_FAILED_TO_LOAD_MAKE_MAN = 10,
IGLOO_FAILED_TO_LOAD_TARG_MAN = 11,
}
#[derive(Debug)]
#[derive(PartialEq)]
#[derive(Clone)]
pub struct IglooEnvInfo
{
// Current Working Directory
@ -129,18 +132,18 @@ impl Igloo
/// It is really only here to help me debug.
///
/// The Inst Type is only returned for usage outside of this struct.
pub fn start(&self) -> Result<IglooInstType, IglooErrType>
pub fn start(&mut self) -> Result<IglooInstType, IglooErrType>
{
let mut res_error = IGLOO_ERR_NONE;
let mut res_type = IGLOO_NULL;
// Load manifests first
self.make_manifest.clone().merge(
self.make_manifest.merge(
config::File::with_name(
IglooEnvInfo::info().esfd.join("manifest/make-manifest.toml")
.to_str()
.unwrap()))
.unwrap();
self.target_manifest.clone().merge(
self.target_manifest.merge(
config::File::with_name(
IglooEnvInfo::info().esfd.join("manifest/target-manifest.toml")
.to_str()
@ -208,7 +211,12 @@ impl Igloo
.unwrap().1
.value_of("target")
.unwrap();
IglooAction::new(prj_name, target);
let res_err = IglooAction::new(
self, prj_name, target);
if res_err != IglooErrType::IGLOO_ERR_NONE
{
return Err(res_err)
}
}
else
{

@ -1,14 +1,16 @@
/// Contains subcommand functions for igloo actions like new, run, push, etc..
pub mod IglooAction
{
use crate::igloo_manifest::IglooManifest;
use crate::igloo::{Igloo, IglooErrType, IglooEnvInfo};
use crate::igloo_prj::IglooPrj;
pub fn run(prj_name: &str, target: &str) -> IglooErrType
{
let res_err: IglooErrType = IglooErrType::IGLOO_ERR_NONE;
res_err
}
pub fn new(prj_name: &str, target: &str)
pub fn new(inst: &Igloo, prj_name: &str, target: &str)
-> IglooErrType
{
let mut res_err: IglooErrType = IglooErrType::IGLOO_ERR_NONE;
@ -27,66 +29,22 @@ pub mod IglooAction
res_err = IglooErrType::IGLOO_FOLDER_ALREADY_EXISTS;
return res_err
}
// Create new directory
let mut active_dir = IglooEnvInfo::info().cwd;
println!("Active Directory: {:?}", active_dir.display());
active_dir.push(prj_name);
match std::fs::create_dir(&active_dir)
{
Err(e) => println!("{:?}", e),
_ => (),
}
println!("Active Directory: {:?}", active_dir.display());
println!("Creating .igloo dir...");
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join(".igloo"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("src"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("inc"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("cfg"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("ESF"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
// load targets
//create symlinks in ESF
match std::os::unix::fs::symlink("", "")
{
Err(e) => println!("{:?}", e),
let mut project = IglooPrj::new(inst, prj_name, target);
match project
{
Err(e) =>
{
println!("Error spawning project: {:?}", e);
res_err = e;
return res_err
}
_ => (),
}
println!("Displaying contents of {:?}", active_dir.display());
for entry in active_dir.read_dir()
.unwrap()
let res_err = project.unwrap().populate();
if res_err != IglooErrType::IGLOO_ERR_NONE
{
let dir = entry.unwrap();
println!("{:?}", dir.file_name());
return res_err
}
res_err
}

@ -2,50 +2,71 @@
pub mod IglooManifest
{
use crate::igloo::{Igloo, IglooErrType, IglooEnvInfo};
pub fn target_exists(inst: &Igloo, name: &str) -> bool
pub fn target_exists(inst: &Igloo, name: &str) -> Result<bool, IglooErrType>
{
let mut ret: bool = false;
loop
let mut ret: bool = true;
let mut res_err = IglooErrType::IGLOO_ERR_NONE;
if name.is_empty()
{
if name.is_empty()
{
ret = false;
break;
}
return Err(IglooErrType::IGLOO_INVALID_TARGET)
}
let make_table = inst.target_manifest.get_table("target.make").unwrap();
let manifest_table = inst.target_manifest.get_table("target.manifest").unwrap();
match make_table.get(name)
let make_table = inst.target_manifest.get_table("target.make");
match make_table
{
Ok(v) =>
{
Some(v) =>
match v.get(name)
{
println!("target.make entry for \"{}\" exists!", name);
ret = true;
Some(v) =>
{
println!("target.make entry for \"{}\" exists!", name);
}
None =>
{
println!("target.make entry for \"{}\" does not exist", name);
ret = false;
}
}
None =>
{
ret = false;
}
}
if !ret
}
Err(e) =>
{
break;
println!("{:?}", e);
return Err(IglooErrType::IGLOO_FAILED_TO_LOAD_MAKE_MAN)
}
}
match manifest_table.get(name)
if !ret
{
return Ok(ret)
}
let target_table = inst.target_manifest.get_table("target.manifest");
match target_table
{
Ok(v) =>
{
Some(v) =>
{
println!("target.manifest entry for \"{}\" exists!", name);
}
None =>
match v.get(name)
{
ret = false;
Some(v) =>
{
println!("target.manifest entry for \"{}\" exists!", name);
}
None =>
{
ret = false;
}
}
}
break; }
ret
Err(e) =>
{
println!("{:?}", e);
return Err(IglooErrType::IGLOO_FAILED_TO_LOAD_TARG_MAN)
}
}
Ok(ret)
}
}

@ -1,5 +1,5 @@
use crate::igloo::{Igloo, IglooEnvInfo, IglooErrType};
use crate::igloo_manifest::{IglooManifest};
use crate::igloo_manifest::IglooManifest;
use std::collections::HashMap;
// New Project
// --- Verify location
@ -35,7 +35,7 @@ impl IglooPrj
}
}
pub fn new(nameIn: &str, targetIn: &str, env_infoIn: &IglooEnvInfo)
pub fn new(inst: &Igloo, nameIn: &str, targetIn: &str)
-> Result<IglooPrj, IglooErrType>
{
let mut res_err = IglooErrType::IGLOO_ERR_NONE;
@ -54,6 +54,26 @@ impl IglooPrj
{
return Err(res_err)
}
match IglooManifest::target_exists(inst, targetIn)
{
Ok(v) =>
{
if v
{
println!("Verified target exists {}", nameIn);
}
else
{
println!("Couldn't verify target exists {}", nameIn);
return Err(IglooErrType::IGLOO_INVALID_TARGET)
}
}
Err(e) =>
{
return Err(e)
}
}
Ok(IglooPrj
{
@ -62,6 +82,79 @@ impl IglooPrj
env_info: IglooEnvInfo::info(),
})
}
pub fn populate(&self) -> IglooErrType
{
// Create new directory
let mut active_dir = IglooEnvInfo::info().cwd;
//println!("Active Directory: {:?}", active_dir.display());
println!("NAME: {}", self.name);
active_dir.push(&self.name);
match std::fs::create_dir(&active_dir)
{
Err(e) => println!("{:?}", e),
_ => (),
}
//println!("Active Directory: {:?}", active_dir.display());
println!("Creating .igloo dir...");
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join(".igloo"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("src"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("inc"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("cfg"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
match std::fs::create_dir(
std::path::Path::new(&active_dir)
.join("ESF"))
{
Err(e) => println!("{:?}", e),
_ => (),
}
// load targets
//create symlinks in ESF
// match std::os::unix::fs::symlink("", "")
// {
// Err(e) => println!("{:?}", e),
// _ => (),
// }
println!("Displaying contents of {:?}", active_dir.display());
for entry in active_dir.read_dir()
.unwrap()
{
let dir = entry.unwrap();
println!("{:?}", dir.file_name());
}
IglooErrType::IGLOO_ERR_NONE
}
pub fn env(self) -> IglooEnvInfo
{
self.env_info.clone()
}
}
impl IglooTarget
@ -76,16 +169,6 @@ impl IglooTarget
}
}
pub fn from(inst: &Igloo, nameIn: &str) -> Result<IglooTarget, IglooErrType>
{
if !IglooManifest::target_exists(inst, nameIn)
{
return Err(IglooErrType::IGLOO_INVALID_TARGET)
}
Ok(IglooTarget::default())
}
}

@ -8,7 +8,7 @@ mod igloo_manifest;
fn main()
{
let ig = igloo::Igloo::new();
let mut ig = igloo::Igloo::new();
let _start_ret = match ig.start()
{
Ok(it) =>

Loading…
Cancel
Save