2019-04-05 03:35:24 +02:00
|
|
|
mod character;
|
2019-04-05 02:35:35 +02:00
|
|
|
mod directory;
|
|
|
|
mod line_break;
|
2019-04-10 15:22:11 +02:00
|
|
|
mod nodejs;
|
2019-04-04 02:14:26 +02:00
|
|
|
|
2019-04-04 18:18:02 +02:00
|
|
|
use ansi_term::Style;
|
2019-04-05 03:35:24 +02:00
|
|
|
use clap::ArgMatches;
|
2019-04-04 18:18:02 +02:00
|
|
|
|
2019-04-12 01:31:30 +02:00
|
|
|
// pub static current_dir: PathBuf = env::current_dir().expect("Unable to identify current directory");
|
|
|
|
// TODO: Currently gets the physical directory. Get the logical directory.
|
|
|
|
|
2019-04-04 18:18:02 +02:00
|
|
|
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 20:18:15 +02:00
|
|
|
let default_suffix = Some(Box::new(Segment {
|
|
|
|
style: Style::default(),
|
|
|
|
value: String::from(" "),
|
|
|
|
prefix: None,
|
2019-04-05 03:35:24 +02:00
|
|
|
suffix: None,
|
2019-04-04 20:18:15 +02:00
|
|
|
}));
|
|
|
|
|
2019-04-04 18:18:02 +02:00
|
|
|
Segment {
|
|
|
|
style: Style::default(),
|
|
|
|
value: String::from(""),
|
|
|
|
prefix: None,
|
2019-04-05 03:35:24 +02:00
|
|
|
suffix: default_suffix,
|
2019-04-04 18:18:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-04-04 02:14:26 +02:00
|
|
|
|
2019-04-04 04:57:50 +02:00
|
|
|
pub fn handle(module: &str, args: &ArgMatches) -> Segment {
|
2019-04-04 02:14:26 +02:00
|
|
|
match module {
|
2019-04-05 02:35:35 +02:00
|
|
|
"dir" | "directory" => directory::segment(&args),
|
2019-04-10 15:22:11 +02:00
|
|
|
"char" | "character" => character::segment(&args),
|
|
|
|
"node" | "nodejs" => nodejs::segment(&args),
|
2019-04-05 02:35:35 +02:00
|
|
|
"line_break" => line_break::segment(&args),
|
2019-04-04 02:14:26 +02:00
|
|
|
|
|
|
|
_ => panic!("Unknown module: {}", module),
|
|
|
|
}
|
|
|
|
}
|