forked from extern/nushell
changed to-float to to-decimal (#1926)
* changed to-float to to-decimal * changed to-float to to-decimal
This commit is contained in:
parent
ac22319a5d
commit
ae72593831
@ -292,7 +292,7 @@ pub fn create_default_context(
|
|||||||
whole_stream_command(Trim),
|
whole_stream_command(Trim),
|
||||||
whole_stream_command(Echo),
|
whole_stream_command(Echo),
|
||||||
whole_stream_command(Str),
|
whole_stream_command(Str),
|
||||||
whole_stream_command(StrToFloat),
|
whole_stream_command(StrToDecimal),
|
||||||
whole_stream_command(StrToInteger),
|
whole_stream_command(StrToInteger),
|
||||||
whole_stream_command(StrDowncase),
|
whole_stream_command(StrDowncase),
|
||||||
whole_stream_command(StrUpcase),
|
whole_stream_command(StrUpcase),
|
||||||
|
@ -230,7 +230,7 @@ pub(crate) use split::SplitRow;
|
|||||||
pub(crate) use split_by::SplitBy;
|
pub(crate) use split_by::SplitBy;
|
||||||
pub(crate) use str_::{
|
pub(crate) use str_::{
|
||||||
Str, StrCapitalize, StrDowncase, StrFindReplace, StrSet, StrSubstring, StrToDatetime,
|
Str, StrCapitalize, StrDowncase, StrFindReplace, StrSet, StrSubstring, StrToDatetime,
|
||||||
StrToFloat, StrToInteger, StrTrim, StrUpcase,
|
StrToDecimal, StrToInteger, StrTrim, StrUpcase,
|
||||||
};
|
};
|
||||||
pub(crate) use sum::Sum;
|
pub(crate) use sum::Sum;
|
||||||
#[allow(unused_imports)]
|
#[allow(unused_imports)]
|
||||||
|
@ -5,7 +5,7 @@ mod find_replace;
|
|||||||
mod set;
|
mod set;
|
||||||
mod substring;
|
mod substring;
|
||||||
mod to_datetime;
|
mod to_datetime;
|
||||||
mod to_float;
|
mod to_decimal;
|
||||||
mod to_integer;
|
mod to_integer;
|
||||||
mod trim;
|
mod trim;
|
||||||
mod upcase;
|
mod upcase;
|
||||||
@ -17,7 +17,7 @@ pub use find_replace::SubCommand as StrFindReplace;
|
|||||||
pub use set::SubCommand as StrSet;
|
pub use set::SubCommand as StrSet;
|
||||||
pub use substring::SubCommand as StrSubstring;
|
pub use substring::SubCommand as StrSubstring;
|
||||||
pub use to_datetime::SubCommand as StrToDatetime;
|
pub use to_datetime::SubCommand as StrToDatetime;
|
||||||
pub use to_float::SubCommand as StrToFloat;
|
pub use to_decimal::SubCommand as StrToDecimal;
|
||||||
pub use to_integer::SubCommand as StrToInteger;
|
pub use to_integer::SubCommand as StrToInteger;
|
||||||
pub use trim::SubCommand as StrTrim;
|
pub use trim::SubCommand as StrTrim;
|
||||||
pub use upcase::SubCommand as StrUpcase;
|
pub use upcase::SubCommand as StrUpcase;
|
||||||
|
@ -21,18 +21,18 @@ pub struct SubCommand;
|
|||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl WholeStreamCommand for SubCommand {
|
impl WholeStreamCommand for SubCommand {
|
||||||
fn name(&self) -> &str {
|
fn name(&self) -> &str {
|
||||||
"str to-float"
|
"str to-decimal"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn signature(&self) -> Signature {
|
fn signature(&self) -> Signature {
|
||||||
Signature::build("str to-float").rest(
|
Signature::build("str to-decimal").rest(
|
||||||
SyntaxShape::ColumnPath,
|
SyntaxShape::ColumnPath,
|
||||||
"optionally convert text into float by column paths",
|
"optionally convert text into decimal by column paths",
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn usage(&self) -> &str {
|
fn usage(&self) -> &str {
|
||||||
"converts text into float"
|
"converts text into decimal"
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn run(
|
async fn run(
|
||||||
@ -45,8 +45,8 @@ impl WholeStreamCommand for SubCommand {
|
|||||||
|
|
||||||
fn examples(&self) -> Vec<Example> {
|
fn examples(&self) -> Vec<Example> {
|
||||||
vec![Example {
|
vec![Example {
|
||||||
description: "Convert to float",
|
description: "Convert to decimal",
|
||||||
example: "echo '3.1415' | str to-float",
|
example: "echo '3.1415' | str to-decimal",
|
||||||
result: None,
|
result: None,
|
||||||
}]
|
}]
|
||||||
}
|
}
|
@ -101,13 +101,13 @@ fn converts_to_int() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn converts_to_float() {
|
fn converts_to_decimal() {
|
||||||
let actual = nu!(
|
let actual = nu!(
|
||||||
cwd: "tests/fixtures/formats", pipeline(
|
cwd: "tests/fixtures/formats", pipeline(
|
||||||
r#"
|
r#"
|
||||||
echo "3.1, 0.0415"
|
echo "3.1, 0.0415"
|
||||||
| split row ","
|
| split row ","
|
||||||
| str to-float
|
| str to-decimal
|
||||||
| sum
|
| sum
|
||||||
"#
|
"#
|
||||||
));
|
));
|
||||||
|
Loading…
Reference in New Issue
Block a user