1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#![allow(warnings)]
extern crate clap;
extern crate config;
mod igloo_action;
mod igloo_project;
mod igloo_target;
use igloo_base::*;
use igloo_base::IglooInstType::*;
use igloo_base::IglooErrType::*;
use igloo_cli::*;
use igloo_manifest::*;
use igloo_project::IglooPrj;
use config::Config;
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
pub struct Igloo
{
cli_conf: clap::ArgMatches,
master_make_man: Config,
master_target_man: Config,
}
impl Igloo
{
pub fn new() -> Igloo
{
Igloo
{
master_make_man: Config::new(),
master_target_man: Config::new(),
cli_conf: igloo_app(),
}
}
pub fn start(&mut self) -> Result<IglooInstType, IglooErrType>
{
let mut res: IglooInstType = Null;
match get_master_make_manifest(&mut self.master_make_man)
{
ErrNone => (),
v =>
{
println!("{:?}", v);
return Err(v)
}
}
match get_master_target_manifest(&mut self.master_target_man)
{
ErrNone => (),
v =>
{
println!("{:?}", v);
return Err(v)
},
}
match igloo_subcommand(&self.cli_conf)
{
Ok(v) => res = v,
Err(e) => return Err(e),
}
if res == Null
{
return Err(ErrUnknown)
}
Ok(res)
}
pub fn run(&self, inst_type: IglooInstType) -> Result<String, IglooErrType>
{
let mut res_err = ErrNone;
let mut prj: IglooPrj;
loop { match inst_type
{
Null => res_err = ErrNone,
New =>
{
let prj_name: &str = self
.cli_conf
.subcommand()
.unwrap().1
.value_of("project_name")
.unwrap();
let target: &str = self
.cli_conf
.subcommand()
.unwrap().1
.value_of("target")
.unwrap();
let res_err = igloo_action::new(
self, prj_name, target);
if res_err != ErrNone
{
return Err(res_err)
}
}
Flash =>
{
}
Run =>
{
}
_ => println!("Unhandled case: {:?}", inst_type),
} break; }
if res_err == ErrNone
{
Ok(String::from("We won!"))
}
else
{
Err(res_err)
}
}
}