summaryrefslogtreecommitdiffstats
path: root/src/modules/python.rs
diff options
context:
space:
mode:
authorMatan Kushner <hello@matchai.me>2019-06-10 15:56:17 +0100
committerGitHub <noreply@github.com>2019-06-10 15:56:17 +0100
commit097f1b05f1d82967fe2a900ccf7ba3597c04ad77 (patch)
treee5419607802145bf2521defd9823d224f937b653 /src/modules/python.rs
parent8239fbd12befad1126e677fa083ce73947d74d8c (diff)
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
Diffstat (limited to 'src/modules/python.rs')
-rw-r--r--src/modules/python.rs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/modules/python.rs b/src/modules/python.rs
index f19da3509..8b72e5187 100644
--- a/src/modules/python.rs
+++ b/src/modules/python.rs
@@ -10,15 +10,10 @@ use super::{Context, Module};
/// - Current directory contains a `.python-version` file
/// - Current directory contains a `requirements.txt` file
/// - Current directory contains a `pyproject.toml` file
-pub fn segment(context: &Context) -> Option<Module> {
+pub fn segment<'a>(context: &'a Context) -> Option<Module<'a>> {
let is_py_project = context
.new_scan_dir()
- .set_files(&[
- "requirements.txt",
- ".python-version",
- "pyproject.toml",
- "pyproject.toml",
- ])
+ .set_files(&["requirements.txt", ".python-version", "pyproject.toml"])
.set_extensions(&["py"])
.scan();
@@ -31,7 +26,7 @@ pub fn segment(context: &Context) -> Option<Module> {
const PYTHON_CHAR: &str = "🐍 ";
let module_color = Color::Yellow.bold();
- let mut module = Module::new("python");
+ let mut module = context.new_module("python");
module.set_style(module_color);
let formatted_version = format_python_version(python_version);