mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-28 07:46:28 +00:00
A bit of tidying up
This commit is contained in:
parent
168a6fd7b1
commit
5086ba2f50
@ -15,12 +15,11 @@ pub fn segment(args: &ArgMatches) -> Segment {
|
|||||||
const COLOR_SUCCESS: Color = Color::Green;
|
const COLOR_SUCCESS: Color = Color::Green;
|
||||||
const COLOR_FAILURE: Color = Color::Red;
|
const COLOR_FAILURE: Color = Color::Red;
|
||||||
|
|
||||||
let color;
|
let color = if args.value_of("status_code").unwrap() == "0" {
|
||||||
if args.value_of("status_code").unwrap() == "0" {
|
COLOR_SUCCESS
|
||||||
color = COLOR_SUCCESS;
|
|
||||||
} else {
|
} else {
|
||||||
color = COLOR_FAILURE;
|
COLOR_FAILURE
|
||||||
}
|
};
|
||||||
|
|
||||||
Segment {
|
Segment {
|
||||||
value: String::from(PROMPT_CHAR),
|
value: String::from(PROMPT_CHAR),
|
||||||
|
@ -36,7 +36,7 @@ pub fn segment(_: &ArgMatches) -> Segment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Segment {
|
Segment {
|
||||||
value: String::from(dir_string),
|
value: dir_string,
|
||||||
style: Style::from(COLOR_DIR).bold(),
|
style: Style::from(COLOR_DIR).bold(),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}
|
}
|
||||||
@ -44,11 +44,12 @@ pub fn segment(_: &ArgMatches) -> Segment {
|
|||||||
|
|
||||||
/// Get the root directory of a git repo
|
/// Get the root directory of a git repo
|
||||||
fn get_repo_root(repo: Repository) -> PathBuf {
|
fn get_repo_root(repo: Repository) -> PathBuf {
|
||||||
match repo.is_bare() {
|
if repo.is_bare() {
|
||||||
// A bare repo will return its root path
|
// Bare repos will return the repo root
|
||||||
true => repo.path().to_path_buf(),
|
repo.path().to_path_buf()
|
||||||
|
} else {
|
||||||
// Non-bare repos will return the path of `.git`
|
// Non-bare repos will return the path of `.git`
|
||||||
false => repo.path().parent().unwrap().to_path_buf(),
|
repo.path().parent().unwrap().to_path_buf()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ pub fn prompt(args: ArgMatches) {
|
|||||||
default_prompt
|
default_prompt
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|module| modules::handle(module, &args))
|
.map(|module| modules::handle(module, &args))
|
||||||
.map(|segment| stringify_segment(segment))
|
.map(stringify_segment)
|
||||||
.for_each(|segment_string| print!("{}", segment_string));
|
.for_each(|segment_string| print!("{}", segment_string));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user