Debian Codegraph @

third_party/rust/mapped_hyph/src/bin/hyf_compile.rs

raw
1 // Copyright 2019-2020 Mozilla Foundation. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10 extern crate log;
11 extern crate mapped_hyph;
12
13 use std::env;
14 use std::fs::File;
15
16 struct Logger {}
17
18 impl log::Log for Logger {
19 fn enabled(&self, _: &log::Metadata) -> bool {
20 true
21 }
22
23 fn log(&self, record: &log::Record) {
24 eprintln!("{} - {}", record.level(), record.args());
25 }
26
27 fn flush(&self) {}
28 }
29
30 static LOGGER: Logger = Logger {};
31
32 fn main() -> std::io::Result<()> {
33 unsafe { log::set_logger_racy(&LOGGER).unwrap() };
34
35 let args: Vec<String> = env::args().collect();
36 if args.len() == 3 {
37 let in_file = File::open(&args[1])?;
38 let mut out_file = File::create(&args[2])?;
39 mapped_hyph::builder::compile(&in_file, &mut out_file, true)?;
40 } else {
41 println!("usage: hyf_compile <pattern-file> <output-file>");
42 }
43 Ok(())
44 }