mirror of
https://github.com/nushell/nushell
synced 2024-12-27 05:23:11 +00:00
Remove parser keywords label from commands that do not need it (#8780)
This commit is contained in:
parent
c12b4b4af7
commit
e54b867e8e
9 changed files with 21 additions and 64 deletions
|
@ -20,15 +20,6 @@ impl Command for Break {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
|
|
|
@ -20,15 +20,6 @@ impl Command for Continue {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
_engine_state: &EngineState,
|
||||
|
|
|
@ -40,15 +40,6 @@ impl Command for If {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
|
|
@ -25,15 +25,6 @@ impl Command for Loop {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
|
|
@ -29,15 +29,6 @@ impl Command for Match {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
|
|
@ -36,15 +36,6 @@ impl Command for Try {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
|
|
@ -30,15 +30,6 @@ impl Command for While {
|
|||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn extra_usage(&self) -> &str {
|
||||
r#"This command is a parser keyword. For details, check:
|
||||
https://www.nushell.sh/book/thinking_in_nu.html"#
|
||||
}
|
||||
|
||||
fn is_parser_keyword(&self) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn run(
|
||||
&self,
|
||||
engine_state: &EngineState,
|
||||
|
|
|
@ -126,6 +126,18 @@ fn alias_invalid_expression() {
|
|||
assert!(actual.err.contains("cant_alias_expression"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alias_if() {
|
||||
let actual = nu!(r#" alias spam = if true { 'spam' } else { 'eggs' }; spam "#);
|
||||
assert_eq!(actual.out, "spam");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn alias_match() {
|
||||
let actual = nu!(r#" alias spam = match 3 { 1..10 => 'yes!' }; spam "#);
|
||||
assert_eq!(actual.out, "yes!");
|
||||
}
|
||||
|
||||
// Issue https://github.com/nushell/nushell/issues/8103
|
||||
#[test]
|
||||
fn alias_multiword_name() {
|
||||
|
|
|
@ -798,8 +798,16 @@ pub fn parse_alias(
|
|||
let _equals = working_set.get_span_contents(spans[split_id + 1]);
|
||||
|
||||
let replacement_spans = &spans[(split_id + 2)..];
|
||||
let first_bytes = working_set.get_span_contents(replacement_spans[0]);
|
||||
|
||||
if is_math_expression_like(working_set, replacement_spans[0], expand_aliases_denylist) {
|
||||
if first_bytes != b"if"
|
||||
&& first_bytes != b"match"
|
||||
&& is_math_expression_like(
|
||||
working_set,
|
||||
replacement_spans[0],
|
||||
expand_aliases_denylist,
|
||||
)
|
||||
{
|
||||
// TODO: Maybe we need to implement a Display trait for Expression?
|
||||
let (expr, _) = parse_expression(
|
||||
working_set,
|
||||
|
|
Loading…
Reference in a new issue