feat(polars): rename polars replace to polars str-replace and polars replace-all to polars str-replace-all

This commit is contained in:
pyz 2025-05-07 08:12:26 -04:00
parent a340511e95
commit f264f656ff
3 changed files with 18 additions and 18 deletions

View File

@ -1,9 +1,9 @@
mod concat_str;
mod contains;
mod replace;
mod replace_all;
mod str_join;
mod str_lengths;
mod str_replace;
mod str_replace_all;
mod str_slice;
mod str_split;
mod str_strip_chars;
@ -15,10 +15,10 @@ use nu_plugin::PluginCommand;
pub use concat_str::ExprConcatStr;
pub use contains::Contains;
pub use replace::Replace;
pub use replace_all::ReplaceAll;
pub use str_join::StrJoin;
pub use str_lengths::StrLengths;
pub use str_replace::StrReplace;
pub use str_replace_all::StrReplaceAll;
pub use str_slice::StrSlice;
pub use to_lowercase::ToLowerCase;
pub use to_uppercase::ToUpperCase;
@ -27,8 +27,8 @@ pub(crate) fn string_commands() -> Vec<Box<dyn PluginCommand<Plugin = PolarsPlug
vec![
Box::new(ExprConcatStr),
Box::new(Contains),
Box::new(Replace),
Box::new(ReplaceAll),
Box::new(StrReplace),
Box::new(StrReplaceAll),
Box::new(str_split::StrSplit),
Box::new(str_strip_chars::StrStripChars),
Box::new(StrJoin),

View File

@ -16,13 +16,13 @@ use nu_protocol::{
use polars::prelude::{lit, IntoSeries, StringNameSpaceImpl};
#[derive(Clone)]
pub struct Replace;
pub struct StrReplace;
impl PluginCommand for Replace {
impl PluginCommand for StrReplace {
type Plugin = PolarsPlugin;
fn name(&self) -> &str {
"polars replace"
"polars str-replace"
}
fn description(&self) -> &str {
@ -61,7 +61,7 @@ impl PluginCommand for Replace {
Example {
description: "Replaces string in column",
example:
"[[a]; [abc] [abcabc]] | polars into-df | polars select (polars col a | polars replace --pattern ab --replace AB) | polars collect",
"[[a]; [abc] [abcabc]] | polars into-df | polars select (polars col a | polars str-replace --pattern ab --replace AB) | polars collect",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
@ -80,7 +80,7 @@ impl PluginCommand for Replace {
Example {
description: "Replaces string",
example:
"[abc abc abc] | polars into-df | polars replace --pattern ab --replace AB",
"[abc abc abc] | polars into-df | polars str-replace --pattern ab --replace AB",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
@ -197,6 +197,6 @@ mod test {
#[test]
fn test_examples() -> Result<(), ShellError> {
test_polars_plugin_command(&Replace)
test_polars_plugin_command(&StrReplace)
}
}

View File

@ -16,13 +16,13 @@ use nu_protocol::{
use polars::prelude::{lit, IntoSeries, StringNameSpaceImpl};
#[derive(Clone)]
pub struct ReplaceAll;
pub struct StrReplaceAll;
impl PluginCommand for ReplaceAll {
impl PluginCommand for StrReplaceAll {
type Plugin = PolarsPlugin;
fn name(&self) -> &str {
"polars replace-all"
"polars str-replace-all"
}
fn description(&self) -> &str {
@ -61,7 +61,7 @@ impl PluginCommand for ReplaceAll {
Example {
description: "Replaces string in a column",
example:
"[[a]; [abac] [abac] [abac]] | polars into-df | polars select (polars col a | polars replace-all --pattern a --replace A) | polars collect",
"[[a]; [abac] [abac] [abac]] | polars into-df | polars select (polars col a | polars str-replace-all --pattern a --replace A) | polars collect",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
@ -81,7 +81,7 @@ impl PluginCommand for ReplaceAll {
Example {
description: "Replaces string",
example:
"[abac abac abac] | polars into-df | polars replace-all --pattern a --replace A",
"[abac abac abac] | polars into-df | polars str-replace-all --pattern a --replace A",
result: Some(
NuDataFrame::try_from_columns(
vec![Column::new(
@ -198,6 +198,6 @@ mod test {
#[test]
fn test_examples() -> Result<(), ShellError> {
test_polars_plugin_command(&ReplaceAll)
test_polars_plugin_command(&StrReplaceAll)
}
}