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
#![feature(exhaustive_patterns)]
#![feature(generator_trait)]
#![feature(generators)]
#![feature(never_type)]
#![deny(elided_lifetimes_in_paths)]
#![warn(missing_docs)]
#![warn(clippy::pedantic)]
pub mod cli;
pub mod itm;
pub mod output;
pub const PORTS_COUNT: usize = 32;
use anyhow::Result;
use cli::Cli;
use output::Output;
use std::{
fs::File,
io::{stdin, Read},
};
impl Cli {
pub fn run(&self) -> Result<()> {
let outputs = Output::open_all(&self.outputs)?;
let mut parser = itm::Parser::new(&outputs)?;
if let Some(path) = &self.input {
for byte in File::open(path)?.bytes() {
parser.pump(byte?)?;
}
} else {
for byte in stdin().lock().bytes() {
parser.pump(byte?)?;
}
}
Ok(())
}
}