adding config stuff. think im going to split it up later, but this is fine for now
parent
3231752235
commit
688d14bf9b
@ -1,67 +0,0 @@
|
||||
#[macro_use]
|
||||
extern crate clap;
|
||||
use clap::{Arg, App};
|
||||
|
||||
fn main()
|
||||
{
|
||||
let str1 = "v";
|
||||
let str2 = crate_version!();
|
||||
let str3 = str1.to_owned() + str2;
|
||||
println!("{}", str3);
|
||||
let matches = App::new("Igloo")
|
||||
.version(&*("v".to_owned() + crate_version!()))
|
||||
.author(crate_authors!())
|
||||
.about("Stuff")
|
||||
.arg(Arg::with_name("v")
|
||||
.short('v')
|
||||
.multiple(true)
|
||||
.about("Sets the level of verbosity"))
|
||||
.subcommand(App::new("new")
|
||||
.about("Creates a new igloo project")
|
||||
.arg(
|
||||
Arg::new("NAME")
|
||||
.required(true)
|
||||
.about("The name of your new project")))
|
||||
.subcommand(App::new("run")
|
||||
.about("Builds and runs project on target selected in config file")
|
||||
.arg(Arg::new("RELEASE")
|
||||
.short('R')
|
||||
.long("release")
|
||||
.about("Run as the release build"))
|
||||
.arg(Arg::new("DEBUG")
|
||||
.short('D')
|
||||
.long("debug")
|
||||
.about("Run as the debug build"))
|
||||
.arg(Arg::new("FRESH")
|
||||
.short('F')
|
||||
.long("fresh")
|
||||
.about("Clean project, compile, and run")))
|
||||
.subcommand(App::new("clean")
|
||||
.about("Cleans project")
|
||||
.version("0.0")
|
||||
.arg(Arg::new("debug")
|
||||
.short('d')
|
||||
.about("print some debug information verbosely")))
|
||||
.get_matches();
|
||||
|
||||
|
||||
match matches.subcommand()
|
||||
{
|
||||
("new", Some(new_matches)) =>
|
||||
{
|
||||
println!("Creating new project named {}", new_matches.value_of("NAME").unwrap());
|
||||
}
|
||||
("run", Some(run_matches)) =>
|
||||
{
|
||||
("RELEASE") => println!("Running as release build"),
|
||||
("DEBUG") => println!("Running as debug build"),
|
||||
("FRESH") => println!("Running as fresh!"),
|
||||
("", None) => println!("No subarg was used!"),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
("", None) => println!("No subcommand was used"),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
use std::vec::Vec;
|
||||
use std::string::String;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt::Display;
|
||||
use config::*;
|
||||
|
||||
struct McuManifest
|
||||
{
|
||||
ep_deps: HashMap<String, config::Value>,
|
||||
makefile_default_src_files: Vec<config::Value>,
|
||||
makefile_default_inc_dirs: Vec<config::Value>,
|
||||
drivers: Vec<config::Value>,
|
||||
modules: Vec<config::Value>,
|
||||
}
|
||||
impl Display for McuManifest
|
||||
{
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result
|
||||
{
|
||||
// print ep deps
|
||||
write!(f, "Printing EP DEPS:\n").unwrap();
|
||||
for dep in &self.ep_deps
|
||||
{
|
||||
write!(f, "{}: {}\n", &dep.0, &dep.1).unwrap();
|
||||
}
|
||||
|
||||
// print makefile default src files
|
||||
write!(f, "\nDefault makefile sources:\n").unwrap();
|
||||
for src_file in &self.makefile_default_src_files
|
||||
{
|
||||
write!(f, "{}\n", &src_file).unwrap();
|
||||
}
|
||||
|
||||
// print makefile default inc dirs
|
||||
for inc_dir in &self.makefile_default_inc_dirs
|
||||
{
|
||||
write!(f, "{}\n", &inc_dir).unwrap();
|
||||
}
|
||||
|
||||
// Available drivers
|
||||
write!(f, "\nAvailable drivers:\n").unwrap();
|
||||
for driver in &self.drivers
|
||||
{
|
||||
write!(f, "{}\n", &driver).unwrap();
|
||||
}
|
||||
|
||||
// Available modules
|
||||
write!(f, "\nAvailable modules:\n").unwrap();
|
||||
for module in &self.modules
|
||||
{
|
||||
write!(f, "{}\n", &module).unwrap();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
fn yml_to_mcu_manifest(conf: &mut config::Config) -> McuManifest
|
||||
{
|
||||
McuManifest
|
||||
{
|
||||
ep_deps: conf.get_table("EP_DEPS").unwrap_or_default(),
|
||||
makefile_default_inc_dirs: conf.get_array("MAKEFILE_DEFAULT_INC_DIRS").unwrap_or_default(),
|
||||
makefile_default_src_files: conf.get_array("MAKEFILE_DEFAULT_SRC_FILES").unwrap_or_default(),
|
||||
drivers: conf.get_array("DRIVERS").unwrap_or_default(),
|
||||
modules: conf.get_array("MODULES").unwrap_or_default(),
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue