PrettyPrompt/src/main.rs
2024-11-26 12:34:31 +05:30

46 lines
1.1 KiB
Rust

mod indicators {
pub mod error;
pub mod git;
pub mod path;
pub mod ssh;
pub mod user;
}
use crate::indicators::error;
use crate::indicators::git;
use crate::indicators::path;
use crate::indicators::ssh;
use crate::indicators::user;
fn main() {
let cmd_args: Vec<String> = std::env::args().collect();
let mut prompt: String = String::new();
let indicate_user: bool = true;
let indicate_ssh: bool = true;
let indicate_err: bool = true;
let indicate_git_branch: bool = true;
let pwd: bool = true;
if pwd {
prompt += &path::pwd().to_string();
}
if indicate_ssh {
prompt += &ssh::indicator().to_string();
}
if indicate_git_branch {
let git_info = git::info();
match git_info {
Some((_repo, branch)) => prompt += &git::indicator(Some(branch)).to_string(),
None => prompt += &git::indicator(None).to_string(),
};
}
if indicate_user {
prompt += &user::indicator().to_string();
}
if indicate_err {
prompt += &error::indicator(cmd_args).to_string();
}
print!("{prompt} ");
}