2 * parameter-lister (Rust implementation)
3 * Copyright © 2016 Vojtěch Král <vojtech@kral.hk>
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 use std::collections::HashMap;
26 use outputmodule::OutputModule;
27 use terminalmodule::TerminalModule;
28 use xmlmodule::XMLModule;
30 static ENV_OUTPUT_MODULE_NAME: &'static str = "PARAMETER_LISTER_OUTPUT";
34 let mut modules: HashMap<_, Box<OutputModule>> = HashMap::new();
35 modules.insert(terminalmodule::MOD_NAME, Box::new(TerminalModule::new()));
36 modules.insert(xmlmodule::MOD_NAME, Box::new(XMLModule::new()));
38 let module_name = env::var(ENV_OUTPUT_MODULE_NAME).unwrap_or(String::from("terminal"));
39 let module = modules.get(&*module_name).expect(&*format!("No such module: {}", module_name));
41 match module.process(&mut io::stdout(), env::args().collect()) {
43 Err(msg) => panic!("Error while processing output with module {}: {}", module_name, msg),