2019-04-04 02:14:26 +02:00
|
|
|
use crate::modules;
|
2019-04-04 18:18:02 +02:00
|
|
|
use crate::modules::Segment;
|
2019-04-04 04:57:50 +02:00
|
|
|
use clap::ArgMatches;
|
2019-04-04 02:14:26 +02:00
|
|
|
|
2019-04-04 04:57:50 +02:00
|
|
|
pub fn prompt(args: ArgMatches) {
|
2019-04-04 20:18:15 +02:00
|
|
|
let default_prompt = vec!["dir", "char"];
|
2019-04-04 02:14:26 +02:00
|
|
|
|
|
|
|
for module in default_prompt {
|
2019-04-04 04:57:50 +02:00
|
|
|
let segment = modules::handle(module, &args);
|
2019-04-04 02:14:26 +02:00
|
|
|
print_segment(segment);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-04 22:59:03 +02:00
|
|
|
pub fn print_segment(segment: Segment) {
|
2019-04-04 02:14:26 +02:00
|
|
|
let Segment {
|
|
|
|
prefix,
|
|
|
|
value,
|
|
|
|
style,
|
|
|
|
suffix,
|
|
|
|
} = segment;
|
|
|
|
|
|
|
|
if let Some(prefix) = prefix {
|
|
|
|
print_segment(*prefix);
|
|
|
|
}
|
|
|
|
|
|
|
|
print!("{}", style.paint(value));
|
|
|
|
|
|
|
|
if let Some(suffix) = suffix {
|
|
|
|
print_segment(*suffix);
|
|
|
|
}
|
|
|
|
}
|