mirror of
https://github.com/nushell/nushell.git
synced 2025-08-14 06:48:35 +02:00
Use IntoValue
in config code (#13751)
# Description Cleans up and refactors the config code using the `IntoValue` macro. Shoutout to @cptpiepmatz for making the macro! # User-Facing Changes Should be none. # After Submitting Somehow refactor the reverse transformation.
This commit is contained in:
@ -8,8 +8,8 @@ pub fn format_filesize_from_conf(num_bytes: i64, config: &Config) -> String {
|
||||
// and filesize_metric is false, return KiB
|
||||
format_filesize(
|
||||
num_bytes,
|
||||
config.filesize_format.as_str(),
|
||||
Some(config.filesize_metric),
|
||||
&config.filesize.format,
|
||||
Some(config.filesize.metric),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -832,7 +832,7 @@ impl Value {
|
||||
Value::Float { val, .. } => val.to_string(),
|
||||
Value::Filesize { val, .. } => format_filesize_from_conf(*val, config),
|
||||
Value::Duration { val, .. } => format_duration(*val),
|
||||
Value::Date { val, .. } => match &config.datetime_normal_format {
|
||||
Value::Date { val, .. } => match &config.datetime_format.normal {
|
||||
Some(format) => self.format_datetime(val, format),
|
||||
None => {
|
||||
format!(
|
||||
@ -886,7 +886,7 @@ impl Value {
|
||||
/// - "[record {n} fields]"
|
||||
pub fn to_abbreviated_string(&self, config: &Config) -> String {
|
||||
match self {
|
||||
Value::Date { val, .. } => match &config.datetime_table_format {
|
||||
Value::Date { val, .. } => match &config.datetime_format.table {
|
||||
Some(format) => self.format_datetime(val, format),
|
||||
None => HumanTime::from(*val).to_string(),
|
||||
},
|
||||
|
Reference in New Issue
Block a user