-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.rs
More file actions
44 lines (41 loc) · 1.56 KB
/
main.rs
File metadata and controls
44 lines (41 loc) · 1.56 KB
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
//^
//^ HEAD
//^
//> HEAD -> FLAGS
#![allow(unused_variables)]
#![allow(nonstandard_style)]
#![feature(if_let_guard)]
//> HEAD -> LOCAL
use mathsys::{
prelude::ExitCode,
TRANSFORMERS,
settings::{
Settings,
noise::Noise
},
Data
};
//> TARGETS -> WRAPPER
pub fn main() -> ExitCode {
let settings = match Settings::cli() {
Ok(settings) => settings,
Err(issue) => return ExitCode::from(issue.consume())
};
for result in TRANSFORMERS.run(&settings) {
match result.data {
Err(issue) => return ExitCode::from(issue.consume()),
Ok(Data::Version {mathsys, architecture, os, rust}) => if settings.noise.verbose() {println!("Running Mathsys v{mathsys} on {architecture}.{os}~{rust}.")} else {println!("Running Mathsys v{mathsys}.")},
Ok(Data::Tokens {length, tokens, maximum, percentage}) => match settings.noise {
Noise::Debug => println!("{length} / {maximum} ({percentage}%)\n{tokens:#?}"),
Noise::Verbose => println!("{length} / {maximum} ({percentage}%)"),
Noise::Normal | Noise::Quiet => println!("{length} / {maximum}"),
Noise::Zero => println!("{length}")
},
Ok(Data::Check) => if !settings.noise.quiet() {println!("No issues found.")},
Ok(Data::Ast {start}) => println!("{start:#?}"),
Ok(Data::Latex {representation}) => println!("{representation}")
}
if settings.noise.debug() {println!("Executed in {:#?}.", result.time)};
};
return ExitCode::SUCCESS;
}