Add support for prompt configuration (#62)

- Create `Config` struct that is added to `Context` when initialized
- Read `~/.confg/starship.toml` during initialization (can be updated later to also look at `$XDG_CONFIG_HOME`)
- `Context` now has a method for creating modules. This allows us to provide modules with a reference to the configuration specific to that module
This commit is contained in:
Matan Kushner
2019-06-10 15:56:17 +01:00
committed by GitHub
parent 8239fbd12b
commit 097f1b05f1
27 changed files with 196 additions and 182 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ use super::{Context, Module};
/// - Current directory contains a `Gopkg.lock` file
/// - Current directory contains a `.go` file
/// - Current directory contains a `Godeps` directory
pub fn segment(context: &Context) -> Option<Module> {
pub fn segment<'a>(context: &'a Context) -> Option<Module<'a>> {
let is_go_project = context
.new_scan_dir()
.set_files(&["go.mod", "go.sum", "glide.yaml", "Gopkg.yml", "Gopkg.lock"])
@@ -30,7 +30,7 @@ pub fn segment(context: &Context) -> Option<Module> {
const GO_CHAR: &str = "🐹 ";
let module_color = Color::Cyan.bold();
let mut module = Module::new("go");
let mut module = context.new_module("go");
module.set_style(module_color);
let formatted_version = format_go_version(go_version)?;