onto the run function, Igloo::new and Igloo::start work
parent
d33f842166
commit
2afd7d3fd3
@ -0,0 +1,63 @@
|
||||
use clap::ArgMatches;
|
||||
|
||||
use crate::IglooType;
|
||||
use crate::IglooType::*;
|
||||
use crate::IglooStatus;
|
||||
use crate::IglooStatus::*;
|
||||
|
||||
pub fn igloo_subcommand(args: &ArgMatches) -> Result<IglooType, IglooStatus>
|
||||
{
|
||||
let mut _res_type: IglooType = IT_NULL;
|
||||
match args.subcommand_name()
|
||||
{
|
||||
Some("new") =>
|
||||
{
|
||||
println!("Igloo new was called!");
|
||||
_res_type = IT_NEW;
|
||||
}
|
||||
Some("run") =>
|
||||
{
|
||||
println!("Igloo run was called!");
|
||||
_res_type = IT_RUN;
|
||||
}
|
||||
Some("build") =>
|
||||
{
|
||||
println!("Igloo build was called!");
|
||||
_res_type = IT_BUILD;
|
||||
}
|
||||
Some("push") =>
|
||||
{
|
||||
println!("Igloo flash was called!");
|
||||
_res_type = IT_PUSH;
|
||||
}
|
||||
Some("pull") =>
|
||||
{
|
||||
println!("Igloo pull was called!");
|
||||
_res_type = IT_PULL;
|
||||
}
|
||||
Some("erase") =>
|
||||
{
|
||||
println!("Igloo erase was called!");
|
||||
_res_type = IT_ERASE;
|
||||
}
|
||||
Some("info") =>
|
||||
{
|
||||
println!("Igloo info was called!");
|
||||
_res_type = IT_INFO;
|
||||
}
|
||||
Some("target") =>
|
||||
{
|
||||
println!("Igloo target was called");
|
||||
_res_type = IT_TARGET;
|
||||
}
|
||||
None => unreachable!(),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
if _res_type == IT_NULL
|
||||
{
|
||||
return Err(IS_UNKNOWN)
|
||||
}
|
||||
|
||||
Ok(_res_type)
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
#[derive(Debug)]
|
||||
#[derive(PartialEq)]
|
||||
#[derive(Clone)]
|
||||
pub struct IglooEnv
|
||||
{
|
||||
// Current Working Directory
|
||||
pub cwd: PathBuf,
|
||||
// Home Directory
|
||||
pub hd: PathBuf,
|
||||
// ESF Directory
|
||||
pub esfd: PathBuf,
|
||||
}
|
||||
|
||||
impl IglooEnv
|
||||
{
|
||||
pub fn get_env() -> IglooEnvInfo
|
||||
{
|
||||
cwd: env::current_dir().unwrap(),
|
||||
hd: match UserDirs::new()
|
||||
{
|
||||
Some(v) => v.home_dir().to_owned(),
|
||||
None =>
|
||||
{
|
||||
println!("Error: Failed to get home directory.\n\
|
||||
This should never happen. Exiting...");
|
||||
std::process::exit(1);
|
||||
}
|
||||
},
|
||||
esfd: match std::env::var("ESF_DIR")
|
||||
{
|
||||
Ok(v)
|
||||
{
|
||||
std::path::PathBuf::from(&v.to_owned())
|
||||
}
|
||||
Err(e) =>
|
||||
{
|
||||
// Note : Need to change new to return actual errors
|
||||
// instead of exiting early
|
||||
println!("Error: $ESF_DIR not defined as an environment\
|
||||
variable -- {:?}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
// igloo_manifest is a simple collection of functions that work with configs
|
||||
|
||||
use crate::Igloo;
|
||||
|
||||
use crate::IglooStatus;
|
||||
use crate::IglooStatus::*;
|
||||
|
||||
use crate::IglooType;
|
||||
use crate::IglooType::*;
|
||||
|
||||
/// USES: environment variables (home dir, esf dir, current dir)
|
||||
/// DOES: brings target manifest into memory
|
||||
pub fn get_master_target_manifest(inst: &mut Igloo) -> IglooStatus
|
||||
{
|
||||
let mut ret: IglooStatus = IS_GOOD;
|
||||
|
||||
match inst.master_target_manifest.merge(
|
||||
config::File::with_name(
|
||||
inst.env.esfd.join("manifest/target-manifest.toml").to_str.unwrap()))
|
||||
{
|
||||
Ok(_v) => (),
|
||||
Err(e) =>
|
||||
{
|
||||
println!("Error: {:?}", e);
|
||||
ret = IS_FAILED_TO_LOAD_MTM;
|
||||
}
|
||||
}
|
||||
ret
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
pub struct IglooProject
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
impl IglooProject
|
||||
{
|
||||
|
||||
}
|
Loading…
Reference in New Issue