added num-format to allow bytes to be formatted with commas. (#2681)

This commit is contained in:
Darren Schroeder 2020-10-19 12:52:11 -05:00 committed by GitHub
parent cb78bf8fd6
commit bc6c884a14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

1
Cargo.lock generated
View File

@ -3012,6 +3012,7 @@ dependencies = [
"nu-test-support", "nu-test-support",
"nu-value-ext", "nu-value-ext",
"num-bigint 0.3.0", "num-bigint 0.3.0",
"num-format",
"num-traits 0.2.12", "num-traits 0.2.12",
"parking_lot 0.11.0", "parking_lot 0.11.0",
"query_interface", "query_interface",

View File

@ -23,6 +23,7 @@ indexmap = {version = "1.6.0", features = ["serde-1"]}
log = "0.4.11" log = "0.4.11"
num-bigint = {version = "0.3.0", features = ["serde"]} num-bigint = {version = "0.3.0", features = ["serde"]}
num-traits = "0.2.12" num-traits = "0.2.12"
num-format = "0.4.0"
parking_lot = "0.11.0" parking_lot = "0.11.0"
query_interface = "0.3.5" query_interface = "0.3.5"
serde = {version = "1.0.115", features = ["derive"]} serde = {version = "1.0.115", features = ["derive"]}

View File

@ -6,6 +6,7 @@ use nu_protocol::RangeInclusion;
use nu_protocol::{format_primitive, ColumnPath, Dictionary, Primitive, UntaggedValue, Value}; use nu_protocol::{format_primitive, ColumnPath, Dictionary, Primitive, UntaggedValue, Value};
use nu_source::{b, DebugDocBuilder, PrettyDebug, Tag}; use nu_source::{b, DebugDocBuilder, PrettyDebug, Tag};
use num_bigint::BigInt; use num_bigint::BigInt;
use num_format::{Locale, ToFormattedString};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::cmp::Ordering; use std::cmp::Ordering;
use std::fmt::Debug; use std::fmt::Debug;
@ -192,8 +193,8 @@ impl PrettyDebug for FormatInlineShape {
match byte.get_unit() { match byte.get_unit() {
byte_unit::ByteUnit::B => { byte_unit::ByteUnit::B => {
(b::primitive(format!("{}", byte.get_value())) + b::space() + b::kind("B")) let locale_byte = byte.get_value() as u64;
.group() (b::primitive(locale_byte.to_formatted_string(&Locale::en))).group()
} }
_ => b::primitive(byte.format(1)), _ => b::primitive(byte.format(1)),
} }