Files
starship/src/modules/mod.rs
T

42 lines
911 B
Rust
Raw Normal View History

2019-04-03 20:14:26 -04:00
mod char;
2019-04-04 14:18:15 -04:00
mod dir;
2019-04-04 20:33:36 -04:00
mod line_sep;
2019-04-03 20:14:26 -04:00
2019-04-03 22:57:50 -04:00
use clap::ArgMatches;
2019-04-04 12:18:02 -04:00
use ansi_term::Style;
pub struct Segment {
pub style: Style,
pub value: String,
pub prefix: Option<Box<Segment>>,
pub suffix: Option<Box<Segment>>,
}
impl Default for Segment {
fn default() -> Segment {
2019-04-04 14:18:15 -04:00
let default_suffix = Some(Box::new(Segment {
style: Style::default(),
value: String::from(" "),
prefix: None,
suffix: None
}));
2019-04-04 12:18:02 -04:00
Segment {
style: Style::default(),
value: String::from(""),
prefix: None,
2019-04-04 14:18:15 -04:00
suffix: default_suffix
2019-04-04 12:18:02 -04:00
}
}
}
2019-04-03 20:14:26 -04:00
2019-04-03 22:57:50 -04:00
pub fn handle(module: &str, args: &ArgMatches) -> Segment {
2019-04-03 20:14:26 -04:00
match module {
2019-04-03 22:57:50 -04:00
"char" => char::segment(&args),
2019-04-04 14:18:15 -04:00
"dir" => dir::segment(&args),
2019-04-04 20:33:36 -04:00
"line_sep" => line_sep::segment(&args),
2019-04-03 20:14:26 -04:00
_ => panic!("Unknown module: {}", module),
}
}