mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-24 21:57:41 +00:00
feat(docker_context): Configure when module is shown (#2315)
* feat(docker_context): Configure when module is shown This makes it possible to configure when the docker_context module is shown based on the contents of a directory. This should make it possible to be a lot more granular when configuring the module. * Update docs/config/README.md Co-authored-by: David Knaack <davidkna@users.noreply.github.com> Co-authored-by: David Knaack <davidkna@users.noreply.github.com>
This commit is contained in:
parent
856610d53b
commit
e8f463bb57
@ -726,13 +726,16 @@ The `docker_context` module shows the currently active
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
| ----------------- | ---------------------------------- | --------------------------------------------------------------------------------------------------------------- |
|
| ------------------- | ------------------------------------------------------------- | --------------------------------------------------------------------------------- |
|
||||||
| `format` | `"via [$symbol$context]($style) "` | The format for the module. |
|
| `format` | `"via [$symbol$context]($style) "` | The format for the module. |
|
||||||
| `symbol` | `"🐳 "` | The symbol used before displaying the Docker context. |
|
| `symbol` | `"🐳 "` | The symbol used before displaying the Docker context. |
|
||||||
| `style` | `"blue bold"` | The style for the module. |
|
| `only_with_files` | `true` | Only show when there's a match |
|
||||||
| `only_with_files` | `true` | Only show when there's a `docker-compose.yml`, `docker-compose.yaml`, or `Dockerfile` in the current directory. |
|
| `detect_extensions` | `[]` | Which extensions should trigger this module (needs `only_with_files` to be true). |
|
||||||
| `disabled` | `false` | Disables the `docker_context` module. |
|
| `detect_files` | `["docker-compose.yml", "docker-compose.yaml", "Dockerfile"]` | Which filenames should trigger this module (needs `only_with_files` to be true). |
|
||||||
|
| `detect_folders` | `[]` | Which folders should trigger this module (needs `only_with_files` to be true). |
|
||||||
|
| `style` | `"blue bold"` | The style for the module. |
|
||||||
|
| `disabled` | `false` | Disables the `docker_context` module. |
|
||||||
|
|
||||||
### Variables
|
### Variables
|
||||||
|
|
||||||
|
@ -9,6 +9,9 @@ pub struct DockerContextConfig<'a> {
|
|||||||
pub format: &'a str,
|
pub format: &'a str,
|
||||||
pub only_with_files: bool,
|
pub only_with_files: bool,
|
||||||
pub disabled: bool,
|
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 DockerContextConfig<'a> {
|
impl<'a> RootModuleConfig<'a> for DockerContextConfig<'a> {
|
||||||
@ -19,6 +22,9 @@ impl<'a> RootModuleConfig<'a> for DockerContextConfig<'a> {
|
|||||||
format: "via [$symbol$context]($style) ",
|
format: "via [$symbol$context]($style) ",
|
||||||
only_with_files: true,
|
only_with_files: true,
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
detect_extensions: vec![],
|
||||||
|
detect_files: vec!["docker-compose.yml", "docker-compose.yaml", "Dockerfile"],
|
||||||
|
detect_folders: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,14 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
if config.only_with_files
|
if config.only_with_files
|
||||||
&& !context
|
&& !context
|
||||||
.try_begin_scan()?
|
.try_begin_scan()?
|
||||||
.set_files(&["docker-compose.yml", "docker-compose.yaml", "Dockerfile"])
|
.set_files(&config.detect_files)
|
||||||
|
.set_extensions(&config.detect_extensions)
|
||||||
|
.set_folders(&config.detect_folders)
|
||||||
.is_match()
|
.is_match()
|
||||||
{
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let docker_config = PathBuf::from(
|
let docker_config = PathBuf::from(
|
||||||
&context
|
&context
|
||||||
.get_env_os("DOCKER_CONFIG")
|
.get_env_os("DOCKER_CONFIG")
|
||||||
|
Loading…
Reference in New Issue
Block a user