mirror of
https://github.com/nushell/nushell.git
synced 2024-11-22 16:33:37 +01:00
parent
27fdef5479
commit
c3efdf2689
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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<OutputStream, ShellError> {
|
||||
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<OutputStream, ShellError> {
|
||||
@ -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,
|
||||
))
|
@ -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;
|
||||
|
@ -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
|
||||
"#
|
Loading…
Reference in New Issue
Block a user