1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::process;
use combostew::config::Config;
use combostew::processor::ProcessWithConfig;
use crate::app_custom_config::manual_arg;
use crate::help::HelpIndex;
#[derive(Debug, Default)]
pub struct HelpDisplayProcessor;
impl HelpDisplayProcessor {
fn print_help(help: &HelpIndex, topic: &str) {
let page = help.get_topic(&*topic.to_lowercase());
match page {
Some(it) => println!("{}", it.help_text),
None => println!("This topic is unavailable in the user manual. The following topics are available: \n\t* {}", help.get_available_topics()),
}
}
}
impl ProcessWithConfig<()> for HelpDisplayProcessor {
fn process(&self, config: &Config) {
if let Some(topic) = manual_arg(&config.application_specific) {
let help = HelpIndex::default();
if topic == "index" {
println!(
"The following topics are available: \n\t* {}",
help.get_available_topics()
);
} else {
HelpDisplayProcessor::print_help(&help, &topic);
}
process::exit(0);
}
}
}