read_properties

Function read_properties 

Source
pub fn read_properties<R: BufRead>(
    reader: &mut R,
) -> Result<Properties, PropertiesParseError>
Examples found in repository?
examples/read-properties.rs (line 31)
7fn main() {
8    let args: Vec<String> = env::args().collect();
9
10    let [program_name, args @ ..] = &args[..] else {
11        unreachable!("Who wouldn't give me a program name?!");
12    };
13
14    if args.is_empty() {
15        eprintln!("Usage: {} <paths to .properties files...>", program_name);
16        std::process::exit(1);
17    }
18
19    for props_path in args {
20        println!("\nReading {:?}", &props_path);
21
22        let file = match File::open(props_path) {
23            Ok(file) => file,
24            Err(e) => {
25                eprintln!("IO error: {}", e);
26                continue;
27            }
28        };
29
30        let mut reader = BufReader::new(file);
31        match read_properties(&mut reader) {
32            Ok(properties) => println!("{:#?}", properties),
33            Err(e) => eprintln!("Parsing error: {}", e),
34        }
35    }
36}