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