summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/config/README.md17
-rw-r--r--src/configs/vagrant.rs6
-rw-r--r--src/modules/vagrant.rs12
3 files changed, 22 insertions, 13 deletions
diff --git a/docs/config/README.md b/docs/config/README.md
index 9c7858043..67e0d6a4c 100644
--- a/docs/config/README.md
+++ b/docs/config/README.md
@@ -2528,18 +2528,21 @@ show_always = true
## Vagrant
The `vagrant` module shows the currently installed version of Vagrant.
-The module will be shown if any of the following conditions are met:
+By default the module will be shown if any of the following conditions are met:
- The current directory contains a `Vagrantfile` file
### Options
-| Option | Default | Description |
-| ---------- | ---------------------------------- | --------------------------------------------------- |
-| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
-| `symbol` | `"⍱ "` | A format string representing the symbol of Vagrant. |
-| `style` | `"cyan bold"` | The style for the module. |
-| `disabled` | `false` | Disables the `Vagrant` module. |
+| Option | Default | Description |
+| ------------------- | ------------------------------------ | --------------------------------------------------- |
+| `format` | `"via [$symbol($version )]($style)"` | The format for the module. |
+| `symbol` | `"⍱ "` | A format string representing the symbol of Vagrant. |
+| `detect_extensions` | `[]` | Which extensions should trigger this module. |
+| `detect_files` | `["Vagrantfile"]` | Which filenames should trigger this module. |
+| `detect_folders` | `[]` | Which folders should trigger this module. |
+| `style` | `"cyan bold"` | The style for the module. |
+| `disabled` | `false` | Disables the `Vagrant` module. |
### Variables
diff --git a/src/configs/vagrant.rs b/src/configs/vagrant.rs
index cab83c01f..94403bb19 100644
--- a/src/configs/vagrant.rs
+++ b/src/configs/vagrant.rs
@@ -8,6 +8,9 @@ pub struct VagrantConfig<'a> {
pub symbol: &'a str,
pub style: &'a str,
pub disabled: bool,
+ pub detect_extensions: Vec<&'a str>,
+ pub detect_files: Vec<&'a str>,
+ pub detect_folders: Vec<&'a str>,
}
impl<'a> RootModuleConfig<'a> for VagrantConfig<'a> {
@@ -17,6 +20,9 @@ impl<'a> RootModuleConfig<'a> for VagrantConfig<'a> {
symbol: "⍱ ",
style: "cyan bold",
disabled: false,
+ detect_extensions: vec![],
+ detect_files: vec!["Vagrantfile"],
+ detect_folders: vec![],
}
}
}
diff --git a/src/modules/vagrant.rs b/src/modules/vagrant.rs
index 99f8bd6a0..06ebef75b 100644
--- a/src/modules/vagrant.rs
+++ b/src/modules/vagrant.rs
@@ -4,21 +4,21 @@ use crate::configs::vagrant::VagrantConfig;
use crate::formatter::StringFormatter;
/// Creates a module with the current Vagrant version
-///
-/// Will display the Vagrant version if any of the following criteria are met:
-/// - Current directory contains a `Vagrantfile` file
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
+ let mut module = context.new_module("vagrant");
+ let config = VagrantConfig::try_load(module.config);
+
let is_vagrant_project = context
.try_begin_scan()?
- .set_files(&["Vagrantfile"])
+ .set_files(&config.detect_files)
+ .set_extensions(&config.detect_extensions)
+ .set_folders(&config.detect_folders)
.is_match();
if !is_vagrant_project {
return None;
}
- let mut module = context.new_module("vagrant");
- let config = VagrantConfig::try_load(module.config);
let parsed = StringFormatter::new(config.format).and_then(|formatter| {
formatter
.map_meta(|var, _| match var {