mirror of
https://github.com/nushell/nushell
synced 2024-12-27 13:33:16 +00:00
Fix use of export/alias --help
bug (#5332)
* fix alias --help bug Signed-off-by: SuYuheng <yuheng.su@motiong.com> * fix export --help bug Signed-off-by: SuYuheng <yuheng.su@motiong.com> Co-authored-by: SuYuheng <yuheng.su@motiong.com>
This commit is contained in:
parent
187f2454c8
commit
fb8f7b114e
2 changed files with 50 additions and 7 deletions
|
@ -529,6 +529,18 @@ pub fn parse_alias(
|
|||
expand_aliases_denylist,
|
||||
);
|
||||
|
||||
if call.has_flag("help") {
|
||||
return (
|
||||
Pipeline::from_vec(vec![Expression {
|
||||
expr: Expr::Call(call),
|
||||
span: span(spans),
|
||||
ty: Type::Any,
|
||||
custom_completion: None,
|
||||
}]),
|
||||
None,
|
||||
);
|
||||
}
|
||||
|
||||
if spans.len() >= 4 {
|
||||
let alias_name = working_set.get_span_contents(spans[1]);
|
||||
|
||||
|
|
|
@ -4539,13 +4539,44 @@ pub fn parse_builtin_commands(
|
|||
b"module" => parse_module(working_set, &lite_command.parts, expand_aliases_denylist),
|
||||
b"use" => parse_use(working_set, &lite_command.parts, expand_aliases_denylist),
|
||||
b"source" => parse_source(working_set, &lite_command.parts, expand_aliases_denylist),
|
||||
b"export" => (
|
||||
garbage_pipeline(&lite_command.parts),
|
||||
Some(ParseError::UnexpectedKeyword(
|
||||
"export".into(),
|
||||
lite_command.parts[0],
|
||||
)),
|
||||
),
|
||||
b"export" => {
|
||||
if let Some(decl_id) = working_set.find_decl(b"alias") {
|
||||
let (call, _) = parse_internal_call(
|
||||
working_set,
|
||||
lite_command.parts[0],
|
||||
&lite_command.parts[1..],
|
||||
decl_id,
|
||||
expand_aliases_denylist,
|
||||
);
|
||||
if call.has_flag("help") {
|
||||
(
|
||||
Pipeline::from_vec(vec![Expression {
|
||||
expr: Expr::Call(call),
|
||||
span: span(&lite_command.parts),
|
||||
ty: Type::Any,
|
||||
custom_completion: None,
|
||||
}]),
|
||||
None,
|
||||
)
|
||||
} else {
|
||||
(
|
||||
garbage_pipeline(&lite_command.parts),
|
||||
Some(ParseError::UnexpectedKeyword(
|
||||
"export".into(),
|
||||
lite_command.parts[0],
|
||||
)),
|
||||
)
|
||||
}
|
||||
} else {
|
||||
(
|
||||
garbage_pipeline(&lite_command.parts),
|
||||
Some(ParseError::UnexpectedKeyword(
|
||||
"export".into(),
|
||||
lite_command.parts[0],
|
||||
)),
|
||||
)
|
||||
}
|
||||
}
|
||||
b"hide" => parse_hide(working_set, &lite_command.parts, expand_aliases_denylist),
|
||||
#[cfg(feature = "plugin")]
|
||||
b"register" => parse_register(working_set, &lite_command.parts, expand_aliases_denylist),
|
||||
|
|
Loading…
Reference in a new issue