1use std::io::Read;
7use std::path::PathBuf;
8
9pub type CliResult = Result<(), String>;
11
12pub fn read_stdin() -> Result<String, String> {
14 let mut buffer = String::new();
15 std::io::stdin()
16 .read_to_string(&mut buffer)
17 .map_err(|e| format!("error reading stdin: {}", e))?;
18 Ok(buffer)
19}
20
21pub fn read_input(path: &str) -> Result<String, String> {
23 if path == "-" {
24 read_stdin()
25 } else {
26 std::fs::read_to_string(path).map_err(|e| format!("error reading {}: {}", path, e))
27 }
28}
29
30#[derive(Debug, Default)]
32pub struct CommonOpts {
33 pub include_dirs: Vec<PathBuf>,
34 pub prepend_include_dirs: Vec<PathBuf>,
35 pub warnings: Vec<String>,
36 pub force: bool,
37 pub debug: bool,
38 pub verbose: bool,
39 pub output_file: Option<PathBuf>,
40}