summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Turner <jonathandturner@users.noreply.github.com>2021-01-05 12:30:55 +1300
committerGitHub <noreply@github.com>2021-01-05 12:30:55 +1300
commit17a433996eb1ecdc07d1411f28c05c5d8466ed67 (patch)
treed55c00c63b6e7ab79b726b66afb706b3ea99e61e
parentb9bb4692a42c8cd8ccb72c17f03a9a125a70accc (diff)
rename set/set-env to let/let-env (#2859)
-rw-r--r--crates/nu-cli/src/commands.rs8
-rw-r--r--crates/nu-cli/src/commands/default_context.rs4
-rw-r--r--crates/nu-cli/src/commands/if_.rs4
-rw-r--r--crates/nu-cli/src/commands/let_.rs (renamed from crates/nu-cli/src/commands/set.rs)20
-rw-r--r--crates/nu-cli/src/commands/let_env.rs (renamed from crates/nu-cli/src/commands/set_env.rs)16
-rw-r--r--crates/nu-cli/src/examples.rs8
-rw-r--r--tests/shell/pipeline/commands/internal.rs14
7 files changed, 37 insertions, 37 deletions
diff --git a/crates/nu-cli/src/commands.rs b/crates/nu-cli/src/commands.rs
index 7172a146e..e3b04ec90 100644
--- a/crates/nu-cli/src/commands.rs
+++ b/crates/nu-cli/src/commands.rs
@@ -73,6 +73,8 @@ pub(crate) mod insert;
pub(crate) mod into_int;
pub(crate) mod keep;
pub(crate) mod last;
+pub(crate) mod let_;
+pub(crate) mod let_env;
pub(crate) mod lines;
pub(crate) mod ls;
pub(crate) mod math;
@@ -101,8 +103,6 @@ pub(crate) mod save;
pub(crate) mod select;
pub(crate) mod seq;
pub(crate) mod seq_dates;
-pub(crate) mod set;
-pub(crate) mod set_env;
pub(crate) mod shells;
pub(crate) mod shuffle;
pub(crate) mod size;
@@ -212,6 +212,8 @@ pub(crate) use insert::Command as Insert;
pub(crate) use into_int::IntoInt;
pub(crate) use keep::{Keep, KeepUntil, KeepWhile};
pub(crate) use last::Last;
+pub(crate) use let_::Let;
+pub(crate) use let_env::LetEnv;
pub(crate) use lines::Lines;
pub(crate) use ls::Ls;
pub(crate) use math::{
@@ -249,8 +251,6 @@ pub(crate) use save::Save;
pub(crate) use select::Select;
pub(crate) use seq::Seq;
pub(crate) use seq_dates::SeqDates;
-pub(crate) use set::Set;
-pub(crate) use set_env::SetEnv;
pub(crate) use shells::Shells;
pub(crate) use shuffle::Shuffle;
pub(crate) use size::Size;
diff --git a/crates/nu-cli/src/commands/default_context.rs b/crates/nu-cli/src/commands/default_context.rs
index c04425bb4..71ca5bf21 100644
--- a/crates/nu-cli/src/commands/default_context.rs
+++ b/crates/nu-cli/src/commands/default_context.rs
@@ -10,8 +10,8 @@ pub fn create_default_context(interactive: bool) -> Result<EvaluationContext, Bo
context.add_commands(vec![
// Fundamentals
whole_stream_command(NuPlugin),
- whole_stream_command(Set),
- whole_stream_command(SetEnv),
+ whole_stream_command(Let),
+ whole_stream_command(LetEnv),
whole_stream_command(Def),
whole_stream_command(Source),
// System/file operations
diff --git a/crates/nu-cli/src/commands/if_.rs b/crates/nu-cli/src/commands/if_.rs
index 58a076bd7..48894ae52 100644
--- a/crates/nu-cli/src/commands/if_.rs
+++ b/crates/nu-cli/src/commands/if_.rs
@@ -53,12 +53,12 @@ impl WholeStreamCommand for If {
vec![
Example {
description: "Run a block if a condition is true",
- example: "set x = 10; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }",
+ example: "let x = 10; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }",
result: Some(vec![UntaggedValue::string("greater than 5").into()]),
},
Example {
description: "Run a block if a condition is false",
- example: "set x = 1; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }",
+ example: "let x = 1; if $x > 5 { echo 'greater than 5' } { echo 'less than or equal to 5' }",
result: Some(vec![UntaggedValue::string("less than or equal to 5").into()]),
},
]
diff --git a/crates/nu-cli/src/commands/set.rs b/crates/nu-cli/src/commands/let_.rs
index 534b5fc94..b7a04f1da 100644
--- a/crates/nu-cli/src/commands/set.rs
+++ b/crates/nu-cli/src/commands/let_.rs
@@ -5,38 +5,38 @@ use nu_errors::ShellError;
use nu_protocol::{hir::CapturedBlock, hir::ClassifiedCommand, Signature, SyntaxShape};
use nu_source::Tagged;
-pub struct Set;
+pub struct Let;
#[derive(Deserialize)]
-pub struct SetArgs {
+pub struct LetArgs {
pub name: Tagged<String>,
pub equals: Tagged<String>,
pub rhs: CapturedBlock,
}
#[async_trait]
-impl WholeStreamCommand for Set {
+impl WholeStreamCommand for Let {
fn name(&self) -> &str {
- "set"
+ "let"
}
fn signature(&self) -> Signature {
- Signature::build("set")
+ Signature::build("let")
.required("name", SyntaxShape::String, "the name of the variable")
.required("equals", SyntaxShape::String, "the equals sign")
.required(
"expr",
SyntaxShape::MathExpression,
- "the value to set the variable to",
+ "the value for the variable",
)
}
fn usage(&self) -> &str {
- "Create a variable and set it to a value."
+ "Create a variable and give it a value."
}
async fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
- set(args).await
+ letcmd(args).await
}
fn examples(&self) -> Vec<Example> {
@@ -44,11 +44,11 @@ impl WholeStreamCommand for Set {
}
}
-pub async fn set(args: CommandArgs) -> Result<OutputStream, ShellError> {
+pub async fn letcmd(args: CommandArgs) -> Result<OutputStream, ShellError> {
let tag = args.call_info.name_tag.clone();
let ctx = EvaluationContext::from_args(&args);
- let (SetArgs { name, rhs, .. }, _) = args.process().await?;
+ let (LetArgs { name, rhs, .. }, _) = args.process().await?;
let (expr, captured) = {
if rhs.block.block.len() != 1 {
diff --git a/crates/nu-cli/src/commands/set_env.rs b/crates/nu-cli/src/commands/let_env.rs
index 56c7bd15b..a7f118f93 100644
--- a/crates/nu-cli/src/commands/set_env.rs
+++ b/crates/nu-cli/src/commands/let_env.rs
@@ -5,23 +5,23 @@ use nu_errors::ShellError;
use nu_protocol::{hir::CapturedBlock, hir::ClassifiedCommand, Signature, SyntaxShape};
use nu_source::Tagged;
-pub struct SetEnv;
+pub struct LetEnv;
#[derive(Deserialize)]
-pub struct SetEnvArgs {
+pub struct LetEnvArgs {
pub name: Tagged<String>,
pub equals: Tagged<String>,
pub rhs: CapturedBlock,
}
#[async_trait]
-impl WholeStreamCommand for SetEnv {
+impl WholeStreamCommand for LetEnv {
fn name(&self) -> &str {
- "set-env"
+ "let-env"
}
fn signature(&self) -> Signature {
- Signature::build("set-env")
+ Signature::build("let-env")
.required(
"name",
SyntaxShape::String,
@@ -31,12 +31,12 @@ impl WholeStreamCommand for SetEnv {
.required(
"expr",
SyntaxShape::MathExpression,
- "the value to set the environment variable to",
+ "the value for the environment variable",
)
}
fn usage(&self) -> &str {
- "Create an environment variable and set it to a value."
+ "Create an environment variable and give it a value."
}
async fn run(&self, args: CommandArgs) -> Result<OutputStream, ShellError> {
@@ -52,7 +52,7 @@ pub async fn set_env(args: CommandArgs) -> Result<OutputStream, ShellError> {
let tag = args.call_info.name_tag.clone();
let ctx = EvaluationContext::from_args(&args);
- let (SetEnvArgs { name, rhs, .. }, _) = args.process().await?;
+ let (LetEnvArgs { name, rhs, .. }, _) = args.process().await?;
let (expr, captured) = {
if rhs.block.block.len() != 1 {
diff --git a/crates/nu-cli/src/examples.rs b/crates/nu-cli/src/examples.rs
index bf0f72b47..c691d63a4 100644
--- a/crates/nu-cli/src/examples.rs
+++ b/crates/nu-cli/src/examples.rs
@@ -13,7 +13,7 @@ use num_bigint::BigInt;
use crate::commands::classified::block::run_block;
use crate::commands::command::CommandArgs;
use crate::commands::{
- whole_stream_command, BuildString, Command, Each, Echo, First, Get, Keep, Last, Nth, Set,
+ whole_stream_command, BuildString, Command, Each, Echo, First, Get, Keep, Last, Let, Nth,
StrCollect, WholeStreamCommand, Wrap,
};
use crate::evaluation_context::EvaluationContext;
@@ -40,7 +40,7 @@ pub fn test_examples(cmd: Command) -> Result<(), ShellError> {
whole_stream_command(Each {}),
whole_stream_command(Last {}),
whole_stream_command(Nth {}),
- whole_stream_command(Set {}),
+ whole_stream_command(Let {}),
whole_stream_command(StrCollect),
whole_stream_command(Wrap),
cmd,
@@ -98,7 +98,7 @@ pub fn test(cmd: impl WholeStreamCommand + 'static) -> Result<(), ShellError> {
whole_stream_command(Get {}),
whole_stream_command(Keep {}),
whole_stream_command(Each {}),
- whole_stream_command(Set {}),
+ whole_stream_command(Let {}),
whole_stream_command(cmd),
whole_stream_command(StrCollect),
whole_stream_command(Wrap),
@@ -160,7 +160,7 @@ pub fn test_anchors(cmd: Command) -> Result<(), ShellError> {
whole_stream_command(Each {}),
whole_stream_command(Last {}),
whole_stream_command(Nth {}),
- whole_stream_command(Set {}),
+ whole_stream_command(Let {}),
whole_stream_command(StrCollect),
whole_stream_command(Wrap),
cmd,
diff --git a/tests/shell/pipeline/commands/internal.rs b/tests/shell/pipeline/commands/internal.rs
index bfc4d366b..46c43e4ce 100644
--- a/tests/shell/pipeline/commands/internal.rs
+++ b/tests/shell/pipeline/commands/internal.rs
@@ -409,8 +409,8 @@ fn set_variable() {
let actual = nu!(
cwd: ".",
r#"
- set x = 5
- set y = 12
+ let x = 5
+ let y = 12
= $x + $y
"#
);
@@ -423,7 +423,7 @@ fn set_doesnt_leak() {
let actual = nu!(
cwd: ".",
r#"
- do { set x = 5 }; echo $x
+ do { let x = 5 }; echo $x
"#
);
@@ -435,7 +435,7 @@ fn set_env_variable() {
let actual = nu!(
cwd: ".",
r#"
- set-env TESTENVVAR = "hello world"
+ let-env TESTENVVAR = "hello world"
echo $nu.env.TESTENVVAR
"#
);
@@ -448,7 +448,7 @@ fn set_env_doesnt_leak() {
let actual = nu!(
cwd: ".",
r#"
- do { set-env xyz = "my message" }; echo $nu.env.xyz
+ do { let-env xyz = "my message" }; echo $nu.env.xyz
"#
);
@@ -460,7 +460,7 @@ fn proper_shadow_set_env_aliases() {
let actual = nu!(
cwd: ".",
r#"
- set-env DEBUG = true; echo $nu.env.DEBUG | autoview; do { set-env DEBUG = false; echo $nu.env.DEBUG } | autoview; echo $nu.env.DEBUG
+ let-env DEBUG = true; echo $nu.env.DEBUG | autoview; do { let-env DEBUG = false; echo $nu.env.DEBUG } | autoview; echo $nu.env.DEBUG
"#
);
assert_eq!(actual.out, "truefalsetrue");
@@ -471,7 +471,7 @@ fn proper_shadow_set_aliases() {
let actual = nu!(
cwd: ".",
r#"
- set DEBUG = false; echo $DEBUG | autoview; do { set DEBUG = true; echo $DEBUG } | autoview; echo $DEBUG
+ let DEBUG = false; echo $DEBUG | autoview; do { let DEBUG = true; echo $DEBUG } | autoview; echo $DEBUG
"#
);
assert_eq!(actual.out, "falsetruefalse");