- dprint fmt

- fix config-schema

Signed-off-by: xxchan <xxchan22f@gmail.com>
This commit is contained in:
xxchan 2024-08-29 22:23:31 +08:00
parent fa7f1757db
commit 1c4c000a77
No known key found for this signature in database
4 changed files with 143 additions and 20 deletions

View File

@ -377,6 +377,35 @@
}
]
},
"disk_usage": {
"default": {
"all_threshold": null,
"current_threshold": 30,
"default_style": "white bold",
"disabled": true,
"format": "[($prefix )]($style)$symbol$current_storage(\\[$other_storage\\]) ",
"prefix": "",
"separator": "|",
"show_current_name": false,
"show_percentage": true,
"symbol": "💾 ",
"threshold_styles": [
{
"style": "yellow bold",
"threshold": 50
},
{
"style": "red bold",
"threshold": 80
}
]
},
"allOf": [
{
"$ref": "#/definitions/DiskUsedConfig"
}
]
},
"docker_context": {
"default": {
"detect_extensions": [],
@ -2903,6 +2932,93 @@
},
"additionalProperties": false
},
"DiskUsedConfig": {
"type": "object",
"properties": {
"format": {
"default": "[($prefix )]($style)$symbol$current_storage(\\[$other_storage\\]) ",
"type": "string"
},
"symbol": {
"default": "💾 ",
"type": "string"
},
"prefix": {
"default": "",
"type": "string"
},
"separator": {
"default": "|",
"type": "string"
},
"disabled": {
"default": true,
"type": "boolean"
},
"show_percentage": {
"default": true,
"type": "boolean"
},
"current_threshold": {
"default": 30,
"type": [
"integer",
"null"
],
"format": "int64"
},
"all_threshold": {
"default": null,
"type": [
"integer",
"null"
],
"format": "int64"
},
"show_current_name": {
"default": false,
"type": "boolean"
},
"default_style": {
"default": "white bold",
"type": "string"
},
"threshold_styles": {
"default": [
{
"style": "yellow bold",
"threshold": 50
},
{
"style": "red bold",
"threshold": 80
}
],
"type": "array",
"items": {
"$ref": "#/definitions/ThresholdStyle"
}
}
},
"additionalProperties": false
},
"ThresholdStyle": {
"type": "object",
"required": [
"style",
"threshold"
],
"properties": {
"threshold": {
"type": "integer",
"format": "int64"
},
"style": {
"type": "string"
}
},
"additionalProperties": false
},
"DockerContextConfig": {
"type": "object",
"properties": {

View File

@ -1279,19 +1279,19 @@ To enable it, set `disabled` to `false` in your configuration file.
### Options
| Option | Default | Description |
| ------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| `prefix` | ` ` | A prefix for the module output. |
| `format` | `"[($prefix )]($style)$symbol$current_storage(\\[$other_storage\\]) "` | The format for the module. |
| `symbol` | `"💾 "` | The symbol used before displaying the disk used usage. |
| `default_style` | `"white bold"` | The style for the module. |
| `disabled` | `true` | Disables the `disk_usage` module. |
| `separator` | `|` | Used to seprate disk used texts. |
| `show_percentage` | `true` | Switches between `63.05%` and `147GB/233GB`. |
| `current_threshold` | `30` | Hides the current directory disk used if it is less than this value. |
| `all_threshold` | ` ` | Hides all disk used if it is less than this value. |
| `show_current_name` | `false` | Toggles between `💾 sda1: 63.05%` and `💾 63.05%`. |
| `threshold_styles` | [link](#disk-used-style-threshold) | Thresholds and style pairs for disk used |
| Option | Default | Description |
| ------------------- | ---------------------------------------------------------------------- | -------------------------------------------------------------------- |
| `prefix` | `` | A prefix for the module output. |
| `format` | `"[($prefix )]($style)$symbol$current_storage(\\[$other_storage\\]) "` | The format for the module. |
| `symbol` | `"💾 "` | The symbol used before displaying the disk used usage. |
| `default_style` | `"white bold"` | The style for the module. |
| `disabled` | `true` | Disables the `disk_usage` module. |
| `separator` | ` | ` |
| `show_percentage` | `true` | Switches between `63.05%` and `147GB/233GB`. |
| `current_threshold` | `30` | Hides the current directory disk used if it is less than this value. |
| `all_threshold` | `` | Hides all disk used if it is less than this value. |
| `show_current_name` | `false` | Toggles between `💾 sda1: 63.05%` and `💾 63.05%`. |
| `threshold_styles` | [link](#disk-used-style-threshold) | Thresholds and style pairs for disk used |
### Disk Used Style Threshold
@ -1308,13 +1308,13 @@ style = "red bold"
### Variables
| Variable | Example | Description |
| ----------------- | ------------------------- | --------------------------------------------------------------------------------------------- |
| prefix | `used` | A perfix for the prompt. |
| style\* | `white bold` | Mirrors the value of option `default_style`. |
| symbol | `💾 ` | Mirrors the value of option `symbol`. |
| current_storage | `63.05%` | The amount of used space on the current disk. |
| other_storage\*\* | `sda2:63.05%|sdb1:63.05%` | The amount of used space on all disks. Only displays the disks that pass the `all_threshold` |
| Variable | Example | Description |
| ----------------- | ------------ | --------------------------------------------- |
| prefix | `used` | A perfix for the prompt. |
| style\* | `white bold` | Mirrors the value of option `default_style`. |
| symbol | `💾` | Mirrors the value of option `symbol`. |
| current_storage | `63.05%` | The amount of used space on the current disk. |
| other_storage\*\* | `sda2:63.05% | sdb1:63.05%` |
\*: This variable can only be used as a part of a style string
\*\*: Disabled if `all_threshold` is not defined

View File

@ -1,6 +1,11 @@
use serde::{Deserialize, Serialize};
#[derive(Clone, Deserialize, Serialize)]
#[cfg_attr(
feature = "config-schema",
derive(schemars::JsonSchema),
schemars(deny_unknown_fields)
)]
pub struct ThresholdStyle<'a> {
pub threshold: i64,
pub style: &'a str,

View File

@ -152,6 +152,8 @@ pub struct FullConfig<'a> {
#[serde(borrow)]
direnv: direnv::DirenvConfig<'a>,
#[serde(borrow)]
disk_usage: disk_usage::DiskUsedConfig<'a>,
#[serde(borrow)]
docker_context: docker_context::DockerContextConfig<'a>,
#[serde(borrow)]
dotnet: dotnet::DotnetConfig<'a>,