Rename edit command to update. (#1724)

Rename edit command to update.
This commit is contained in:
Andrés N. Robalino 2020-05-07 00:33:30 -05:00 committed by GitHub
parent 27fdef5479
commit c3efdf2689
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 18 additions and 18 deletions

View file

@ -287,7 +287,7 @@ pub fn create_default_context(
whole_stream_command(Reject), whole_stream_command(Reject),
whole_stream_command(Pick), whole_stream_command(Pick),
whole_stream_command(Get), whole_stream_command(Get),
whole_stream_command(Edit), whole_stream_command(Update),
whole_stream_command(Insert), whole_stream_command(Insert),
whole_stream_command(SplitBy), whole_stream_command(SplitBy),
// Row manipulation // Row manipulation

View file

@ -24,7 +24,6 @@ pub(crate) mod drop;
pub(crate) mod du; pub(crate) mod du;
pub(crate) mod each; pub(crate) mod each;
pub(crate) mod echo; pub(crate) mod echo;
pub(crate) mod edit;
pub(crate) mod enter; pub(crate) mod enter;
#[allow(unused)] #[allow(unused)]
pub(crate) mod evaluate_by; pub(crate) mod evaluate_by;
@ -115,6 +114,7 @@ pub(crate) mod to_url;
pub(crate) mod to_yaml; pub(crate) mod to_yaml;
pub(crate) mod trim; pub(crate) mod trim;
pub(crate) mod uniq; pub(crate) mod uniq;
pub(crate) mod update;
pub(crate) mod version; pub(crate) mod version;
pub(crate) mod what; pub(crate) mod what;
pub(crate) mod where_; pub(crate) mod where_;
@ -140,8 +140,8 @@ pub(crate) use drop::Drop;
pub(crate) use du::Du; pub(crate) use du::Du;
pub(crate) use each::Each; pub(crate) use each::Each;
pub(crate) use echo::Echo; pub(crate) use echo::Echo;
pub(crate) use edit::Edit;
pub(crate) use is_empty::IsEmpty; pub(crate) use is_empty::IsEmpty;
pub(crate) use update::Update;
pub(crate) mod kill; pub(crate) mod kill;
pub(crate) use kill::Kill; pub(crate) use kill::Kill;
pub(crate) mod clear; pub(crate) mod clear;

View file

@ -7,25 +7,25 @@ use nu_protocol::{ColumnPath, ReturnSuccess, Signature, SyntaxShape, UntaggedVal
use nu_value_ext::ValueExt; use nu_value_ext::ValueExt;
use futures::stream::once; use futures::stream::once;
pub struct Edit; pub struct Update;
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct EditArgs { pub struct UpdateArgs {
field: ColumnPath, field: ColumnPath,
replacement: Value, replacement: Value,
} }
impl WholeStreamCommand for Edit { impl WholeStreamCommand for Update {
fn name(&self) -> &str { fn name(&self) -> &str {
"edit" "update"
} }
fn signature(&self) -> Signature { fn signature(&self) -> Signature {
Signature::build("edit") Signature::build("update")
.required( .required(
"field", "field",
SyntaxShape::ColumnPath, SyntaxShape::ColumnPath,
"the name of the column to edit", "the name of the column to update",
) )
.required( .required(
"replacement value", "replacement value",
@ -35,7 +35,7 @@ impl WholeStreamCommand for Edit {
} }
fn usage(&self) -> &str { fn usage(&self) -> &str {
"Edit an existing column to have a new value." "Update an existing column to have a new value."
} }
fn run( fn run(
@ -43,12 +43,12 @@ impl WholeStreamCommand for Edit {
args: CommandArgs, args: CommandArgs,
registry: &CommandRegistry, registry: &CommandRegistry,
) -> Result<OutputStream, ShellError> { ) -> Result<OutputStream, ShellError> {
Ok(args.process_raw(registry, edit)?.run()) Ok(args.process_raw(registry, update)?.run())
} }
} }
fn edit( fn update(
EditArgs { field, replacement }: EditArgs, UpdateArgs { field, replacement }: UpdateArgs,
context: RunnableContext, context: RunnableContext,
raw_args: RawCommandArgs, raw_args: RawCommandArgs,
) -> Result<OutputStream, ShellError> { ) -> Result<OutputStream, ShellError> {
@ -93,7 +93,7 @@ fn edit(
Some(v) => yield Ok(ReturnSuccess::Value(v)), Some(v) => yield Ok(ReturnSuccess::Value(v)),
None => { None => {
yield Err(ShellError::labeled_error( yield Err(ShellError::labeled_error(
"edit could not find place to insert column", "update could not find place to insert column",
"column name", "column name",
obj.tag, obj.tag,
)) ))
@ -124,7 +124,7 @@ fn edit(
Some(v) => yield Ok(ReturnSuccess::Value(v)), Some(v) => yield Ok(ReturnSuccess::Value(v)),
None => { None => {
yield Err(ShellError::labeled_error( yield Err(ShellError::labeled_error(
"edit could not find place to insert column", "update could not find place to insert column",
"column name", "column name",
obj.tag, obj.tag,
)) ))

View file

@ -7,7 +7,6 @@ mod cp;
mod default; mod default;
mod drop; mod drop;
mod each; mod each;
mod edit;
mod enter; mod enter;
mod first; mod first;
mod format; mod format;
@ -45,6 +44,7 @@ mod sum;
mod touch; mod touch;
mod trim; mod trim;
mod uniq; mod uniq;
mod update;
mod where_; mod where_;
mod with_env; mod with_env;
mod wrap; mod wrap;

View file

@ -6,7 +6,7 @@ fn sets_the_column() {
cwd: "tests/fixtures/formats", pipeline( cwd: "tests/fixtures/formats", pipeline(
r#" r#"
open cargo_sample.toml 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 | get dev-dependencies.pretty_assertions
| echo $it | echo $it
"# "#
@ -21,7 +21,7 @@ fn sets_the_column_from_a_block_run_output() {
cwd: "tests/fixtures/formats", pipeline( cwd: "tests/fixtures/formats", pipeline(
r#" r#"
open cargo_sample.toml 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 | get dev-dependencies.pretty_assertions
| echo $it | echo $it
"# "#