From c3efdf2689b0bea169a88e65c419045be889cd9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20N=2E=20Robalino?= Date: Thu, 7 May 2020 00:33:30 -0500 Subject: [PATCH] Rename edit command to update. (#1724) Rename edit command to update. --- crates/nu-cli/src/cli.rs | 2 +- crates/nu-cli/src/commands.rs | 4 ++-- .../src/commands/{edit.rs => update.rs} | 24 +++++++++---------- crates/nu-cli/tests/commands/mod.rs | 2 +- .../tests/commands/{edit.rs => update.rs} | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) rename crates/nu-cli/src/commands/{edit.rs => update.rs} (89%) rename crates/nu-cli/tests/commands/{edit.rs => update.rs} (75%) diff --git a/crates/nu-cli/src/cli.rs b/crates/nu-cli/src/cli.rs index 2b69e80979..3455aa178d 100644 --- a/crates/nu-cli/src/cli.rs +++ b/crates/nu-cli/src/cli.rs @@ -287,7 +287,7 @@ pub fn create_default_context( whole_stream_command(Reject), whole_stream_command(Pick), whole_stream_command(Get), - whole_stream_command(Edit), + whole_stream_command(Update), whole_stream_command(Insert), whole_stream_command(SplitBy), // Row manipulation diff --git a/crates/nu-cli/src/commands.rs b/crates/nu-cli/src/commands.rs index aa2589f062..488c263d1c 100644 --- a/crates/nu-cli/src/commands.rs +++ b/crates/nu-cli/src/commands.rs @@ -24,7 +24,6 @@ pub(crate) mod drop; pub(crate) mod du; pub(crate) mod each; pub(crate) mod echo; -pub(crate) mod edit; pub(crate) mod enter; #[allow(unused)] pub(crate) mod evaluate_by; @@ -115,6 +114,7 @@ pub(crate) mod to_url; pub(crate) mod to_yaml; pub(crate) mod trim; pub(crate) mod uniq; +pub(crate) mod update; pub(crate) mod version; pub(crate) mod what; pub(crate) mod where_; @@ -140,8 +140,8 @@ pub(crate) use drop::Drop; pub(crate) use du::Du; pub(crate) use each::Each; pub(crate) use echo::Echo; -pub(crate) use edit::Edit; pub(crate) use is_empty::IsEmpty; +pub(crate) use update::Update; pub(crate) mod kill; pub(crate) use kill::Kill; pub(crate) mod clear; diff --git a/crates/nu-cli/src/commands/edit.rs b/crates/nu-cli/src/commands/update.rs similarity index 89% rename from crates/nu-cli/src/commands/edit.rs rename to crates/nu-cli/src/commands/update.rs index 863c37a71c..7582c42980 100644 --- a/crates/nu-cli/src/commands/edit.rs +++ b/crates/nu-cli/src/commands/update.rs @@ -7,25 +7,25 @@ use nu_protocol::{ColumnPath, ReturnSuccess, Signature, SyntaxShape, UntaggedVal use nu_value_ext::ValueExt; use futures::stream::once; -pub struct Edit; +pub struct Update; #[derive(Deserialize)] -pub struct EditArgs { +pub struct UpdateArgs { field: ColumnPath, replacement: Value, } -impl WholeStreamCommand for Edit { +impl WholeStreamCommand for Update { fn name(&self) -> &str { - "edit" + "update" } fn signature(&self) -> Signature { - Signature::build("edit") + Signature::build("update") .required( "field", SyntaxShape::ColumnPath, - "the name of the column to edit", + "the name of the column to update", ) .required( "replacement value", @@ -35,7 +35,7 @@ impl WholeStreamCommand for Edit { } fn usage(&self) -> &str { - "Edit an existing column to have a new value." + "Update an existing column to have a new value." } fn run( @@ -43,12 +43,12 @@ impl WholeStreamCommand for Edit { args: CommandArgs, registry: &CommandRegistry, ) -> Result { - Ok(args.process_raw(registry, edit)?.run()) + Ok(args.process_raw(registry, update)?.run()) } } -fn edit( - EditArgs { field, replacement }: EditArgs, +fn update( + UpdateArgs { field, replacement }: UpdateArgs, context: RunnableContext, raw_args: RawCommandArgs, ) -> Result { @@ -93,7 +93,7 @@ fn edit( Some(v) => yield Ok(ReturnSuccess::Value(v)), None => { yield Err(ShellError::labeled_error( - "edit could not find place to insert column", + "update could not find place to insert column", "column name", obj.tag, )) @@ -124,7 +124,7 @@ fn edit( Some(v) => yield Ok(ReturnSuccess::Value(v)), None => { yield Err(ShellError::labeled_error( - "edit could not find place to insert column", + "update could not find place to insert column", "column name", obj.tag, )) diff --git a/crates/nu-cli/tests/commands/mod.rs b/crates/nu-cli/tests/commands/mod.rs index 597877fa32..120dcf3f43 100644 --- a/crates/nu-cli/tests/commands/mod.rs +++ b/crates/nu-cli/tests/commands/mod.rs @@ -7,7 +7,6 @@ mod cp; mod default; mod drop; mod each; -mod edit; mod enter; mod first; mod format; @@ -45,6 +44,7 @@ mod sum; mod touch; mod trim; mod uniq; +mod update; mod where_; mod with_env; mod wrap; diff --git a/crates/nu-cli/tests/commands/edit.rs b/crates/nu-cli/tests/commands/update.rs similarity index 75% rename from crates/nu-cli/tests/commands/edit.rs rename to crates/nu-cli/tests/commands/update.rs index f8c91a0cfc..1371eb130d 100644 --- a/crates/nu-cli/tests/commands/edit.rs +++ b/crates/nu-cli/tests/commands/update.rs @@ -6,7 +6,7 @@ fn sets_the_column() { cwd: "tests/fixtures/formats", pipeline( r#" open cargo_sample.toml - | edit dev-dependencies.pretty_assertions "0.7.0" + | update dev-dependencies.pretty_assertions "0.7.0" | get dev-dependencies.pretty_assertions | echo $it "# @@ -21,7 +21,7 @@ fn sets_the_column_from_a_block_run_output() { cwd: "tests/fixtures/formats", pipeline( r#" open cargo_sample.toml - | edit dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor } + | update dev-dependencies.pretty_assertions { open cargo_sample.toml | get dev-dependencies.pretty_assertions | inc --minor } | get dev-dependencies.pretty_assertions | echo $it "#