1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-10-03 23:53:07 +00:00
starship/src/print.rs

25 lines
624 B
Rust
Raw Normal View History

2019-04-08 21:35:38 +00:00
use clap::ArgMatches;
2019-04-11 23:31:30 +00:00
use std::io::{self, Write};
2019-04-08 21:35:38 +00:00
2019-04-04 00:14:26 +00:00
use crate::modules;
2019-04-04 02:57:50 +00:00
pub fn prompt(args: ArgMatches) {
2019-04-12 21:49:20 +00:00
let default_prompt = vec!["directory", "nodejs", "line_break", "character"];
2019-04-04 00:14:26 +00:00
2019-04-11 23:31:30 +00:00
// TODO:
// - List files in directory
// - Index binaries in PATH
2019-04-08 21:35:38 +00:00
let stdout = io::stdout();
let mut handle = stdout.lock();
// Write a new line before the prompt
2019-04-12 17:17:20 +00:00
writeln!(handle).unwrap();
2019-04-11 23:31:30 +00:00
2019-04-05 01:35:24 +00:00
default_prompt
2019-04-12 23:11:40 +00:00
.iter()
2019-04-05 00:33:36 +00:00
.map(|module| modules::handle(module, &args))
2019-04-12 23:11:40 +00:00
.map(|segment| segment.output())
2019-04-08 21:35:38 +00:00
.for_each(|segment_string| write!(handle, "{}", segment_string).unwrap());
2019-04-04 00:14:26 +00:00
}