blob: 95a83807de672592a277e9a3194964befb449b39 (
plain)
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
|
use ammonia::Builder;
use std::env;
use std::fs::File;
use std::io::{self, Read, Write};
use std::process;
fn run() -> io::Result<()> {
let input = env::args().nth(1).unwrap_or_else(|| String::from("-"));
let output = env::args().nth(2).unwrap_or_else(|| String::from("-"));
let mut rdr: Box<dyn Read> = if input == "-" {
Box::new(io::stdin())
} else {
Box::new(File::open(input)?)
};
let mut wrt: Box<dyn Write> = if output == "-" {
Box::new(io::stdout())
} else {
Box::new(File::create(output)?)
};
Builder::new()
.clean_from_reader(&mut rdr)?
.write_to(&mut wrt)?;
Ok(())
}
fn main() {
env_logger::init();
if let Err(ref e) = run() {
println!("error: {}", e);
process::exit(1);
}
}
|