resolve comment: rename disk_used to disk_usage

Signed-off-by: xxchan <xxchan22f@gmail.com>
This commit is contained in:
xxchan
2024-08-29 21:58:01 +08:00
parent 168591e0df
commit 56824d8e14
7 changed files with 17 additions and 17 deletions

View File

@ -348,7 +348,7 @@ $sudo\
$cmd_duration\
$line_break\
$jobs\
$disk_used\
$disk_usage\
$battery\
$time\
$status\
@ -1266,7 +1266,7 @@ disabled = false
## Disk Used
The `disk_used` module shows disk used in current directory or any disk specified.
The `disk_usage` module shows disk used in current directory or any disk specified.
By default the moduel only shows the current directory's disk used when it is more than 30%.
@ -1285,7 +1285,7 @@ To enable it, set `disabled` to `false` in your configuration file.
| `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_used` 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. |
@ -1298,10 +1298,10 @@ To enable it, set `disabled` to `false` in your configuration file.
The `threshold_styles` are used to change the style of the disk used display based on the percentage of disk used.
```toml
[[disk_used.threshold_styles]]
[[disk_usage.threshold_styles]]
threshold = 50
style = "yellow bold"
[[disk_used.threshold_styles]]
[[disk_usage.threshold_styles]]
threshold = 80
style = "red bold"
```
@ -1324,7 +1324,7 @@ style = "red bold"
```toml
# ~/.config/starship.toml
[disk_used]
[disk_usage]
disabled = false
show_percentage = true
current_threshold = 0

View File

@ -20,7 +20,7 @@ pub mod dart;
pub mod deno;
pub mod directory;
pub mod direnv;
pub mod disk_used;
pub mod disk_usage;
pub mod docker_context;
pub mod dotnet;
pub mod elixir;

View File

@ -108,7 +108,7 @@ pub const PROMPT_ORDER: &[&str] = &[
"meson",
"spack",
"memory_usage",
"disk_used",
"disk_usage",
"aws",
"gcloud",
"openstack",

View File

@ -93,7 +93,7 @@ pub const ALL_MODULES: &[&str] = &[
"sudo",
"swift",
"terraform",
"disk_used",
"disk_usage",
"time",
"typst",
"username",

View File

@ -8,7 +8,7 @@ use systemstat::{saturating_sub_bytes, Filesystem, Platform, System};
use super::{Context, Module};
use crate::segment::Segment;
use crate::{config::ModuleConfig, configs::disk_used::DiskUsedConfig};
use crate::{config::ModuleConfig, configs::disk_usage::DiskUsedConfig};
use crate::{formatter::StringFormatter, modules::memory_usage::display_bs};
fn get_disk_name(disk: &Filesystem) -> Option<&str> {
@ -17,7 +17,7 @@ fn get_disk_name(disk: &Filesystem) -> Option<&str> {
.and_then(|name| name.to_str())
}
fn format_disk_used(
fn format_disk_usage(
disk: &Filesystem,
config: &DiskUsedConfig,
show_disk_name: bool,
@ -86,7 +86,7 @@ fn get_drive_from_path<'a>(path: &PathBuf, disks: &'a [Filesystem]) -> Option<&'
}
pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let mut module = context.new_module("disk_used");
let mut module = context.new_module("disk_usage");
let config = DiskUsedConfig::try_load(module.config);
if config.disabled {
@ -110,7 +110,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
Some(disk) => {
current_disk = Some(disk);
if should_display_disk(disk, threshold) {
match format_disk_used(disk, &config, config.show_current_name, false, context)
match format_disk_usage(disk, &config, config.show_current_name, false, context)
{
Ok(segments) => {
if !segments.is_empty() {
@ -141,7 +141,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let mut all_segments = Vec::new();
for (i, disk) in display_disks.iter().enumerate() {
match format_disk_used(disk, &config, true, display_disks.len() != i + 1, context) {
match format_disk_usage(disk, &config, true, display_disks.len() != i + 1, context) {
Ok(ref mut segments) => {
all_segments.append(segments);
}

View File

@ -17,7 +17,7 @@ mod dart;
mod deno;
mod directory;
mod direnv;
mod disk_used;
mod disk_usage;
mod docker_context;
mod dotnet;
mod elixir;
@ -130,7 +130,7 @@ pub fn handle<'a>(module: &str, context: &'a Context) -> Option<Module<'a>> {
"deno" => deno::module(context),
"directory" => directory::module(context),
"direnv" => direnv::module(context),
"disk_used" => disk_used::module(context),
"disk_usage" => disk_usage::module(context),
"docker_context" => docker_context::module(context),
"dotnet" => dotnet::module(context),
"elixir" => elixir::module(context),
@ -255,7 +255,7 @@ pub fn description(module: &str) -> &'static str {
"deno" => "The currently installed version of Deno",
"directory" => "The current working directory",
"direnv" => "The currently applied direnv file",
"disk_used" => "Current disk used",
"disk_usage" => "Current disk used",
"docker_context" => "The current docker context",
"dotnet" => "The relevant version of the .NET Core SDK for the current directory",
"elixir" => "The currently installed versions of Elixir and OTP",