1use pom_parser::Configuration;
2use std::process::ExitCode;
3
4fn try_main() -> Result<(), Box<dyn std::error::Error>> {
5 let conf = Configuration::load_path("examples/conf.pom")?;
7 println!(
11 "indenting with {}",
12 conf.get("indentation-type")
13 .ok_or("you must pick an indentation-type!")?
14 );
15 println!("tab width is {}", conf.get_int_or_default("tab-size", 8)?);
18 println!(
21 "show line numbers: {}",
22 conf.get_bool_or_default("show-line-numbers", false)?
23 );
24 println!("C++ extensions: {:?}", conf.get_list("file-extensions.Cpp"));
26
27 println!("===plug-ins===");
28 let plug_ins = conf.section("plug-in");
30 for plug_in in plug_ins.keys() {
31 let plug_in_cfg = plug_ins.section(plug_in);
33 println!(
34 "{plug_in} is {}",
35 if plug_in_cfg.get_bool_or_default("enabled", true)? {
36 "enabled"
37 } else {
38 "disabled"
39 }
40 );
41 println!(
42 "{plug_in} plug-in path: {:?}",
43 plug_in_cfg
44 .get("path")
45 .ok_or_else(|| format!("no path set for plug-in {plug_in}!"))?
46 );
47 }
48 Ok(())
49}
50
51fn main() -> ExitCode {
52 if let Err(e) = try_main() {
53 eprintln!("Error: {e}");
54 return ExitCode::FAILURE;
55 }
56 ExitCode::SUCCESS
57}