mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +01:00
Rename overlay commands (#6375)
* rename from overlay add to overlay use * rename from overlay remove to overlay hide * rename add to use_
This commit is contained in:
parent
c5ca839294
commit
9c4bbe3c63
@ -4,20 +4,20 @@ use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanned, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct OverlayRemove;
|
||||
pub struct OverlayHide;
|
||||
|
||||
impl Command for OverlayRemove {
|
||||
impl Command for OverlayHide {
|
||||
fn name(&self) -> &str {
|
||||
"overlay remove"
|
||||
"overlay hide"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Remove an active overlay"
|
||||
"Hide an active overlay"
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("overlay remove")
|
||||
.optional("name", SyntaxShape::String, "Overlay to remove")
|
||||
Signature::build("overlay hide")
|
||||
.optional("name", SyntaxShape::String, "Overlay to hide")
|
||||
.switch(
|
||||
"keep-custom",
|
||||
"Keep all newly added symbols within the next activated overlay",
|
||||
@ -26,7 +26,7 @@ impl Command for OverlayRemove {
|
||||
.named(
|
||||
"keep-env",
|
||||
SyntaxShape::List(Box::new(SyntaxShape::String)),
|
||||
"List of environment variables to keep from the removed overlay",
|
||||
"List of environment variables to keep from the hidden overlay",
|
||||
Some('e'),
|
||||
)
|
||||
.category(Category::Core)
|
||||
@ -110,31 +110,31 @@ impl Command for OverlayRemove {
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![
|
||||
Example {
|
||||
description: "Remove an overlay created from a module",
|
||||
description: "Hide an overlay created from a module",
|
||||
example: r#"module spam { export def foo [] { "foo" } }
|
||||
overlay add spam
|
||||
overlay remove spam"#,
|
||||
overlay use spam
|
||||
overlay hide spam"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Remove an overlay created from a file",
|
||||
description: "Hide an overlay created from a file",
|
||||
example: r#"echo 'export alias f = "foo"' | save spam.nu
|
||||
overlay add spam.nu
|
||||
overlay remove spam"#,
|
||||
overlay use spam.nu
|
||||
overlay hide spam"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Remove the last activated overlay",
|
||||
description: "Hide the last activated overlay",
|
||||
example: r#"module spam { export env FOO { "foo" } }
|
||||
overlay add spam
|
||||
overlay remove"#,
|
||||
overlay use spam
|
||||
overlay hide"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Keep the current working directory when removing an overlay",
|
||||
example: r#"overlay new spam
|
||||
cd some-dir
|
||||
overlay remove --keep-env [ PWD ] spam"#,
|
||||
overlay hide --keep-env [ PWD ] spam"#,
|
||||
result: None,
|
||||
},
|
||||
]
|
@ -74,7 +74,7 @@ impl Command for OverlayList {
|
||||
vec![Example {
|
||||
description: "Get the last activated overlay",
|
||||
example: r#"module spam { export def foo [] { "foo" } }
|
||||
overlay add spam
|
||||
overlay use spam
|
||||
overlay list | last"#,
|
||||
result: Some(Value::String {
|
||||
val: "spam".to_string(),
|
||||
|
@ -1,11 +1,11 @@
|
||||
mod add;
|
||||
mod command;
|
||||
mod hide;
|
||||
mod list;
|
||||
mod new;
|
||||
mod remove;
|
||||
mod use_;
|
||||
|
||||
pub use add::OverlayAdd;
|
||||
pub use command::Overlay;
|
||||
pub use hide::OverlayHide;
|
||||
pub use list::OverlayList;
|
||||
pub use new::OverlayNew;
|
||||
pub use remove::OverlayRemove;
|
||||
pub use use_::OverlayUse;
|
||||
|
@ -6,23 +6,23 @@ use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Spanne
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct OverlayAdd;
|
||||
pub struct OverlayUse;
|
||||
|
||||
impl Command for OverlayAdd {
|
||||
impl Command for OverlayUse {
|
||||
fn name(&self) -> &str {
|
||||
"overlay add"
|
||||
"overlay use"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Add definitions from a module as an overlay"
|
||||
"Use definitions from a module as an overlay"
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("overlay add")
|
||||
Signature::build("overlay use")
|
||||
.required(
|
||||
"name",
|
||||
SyntaxShape::String,
|
||||
"Module name to create overlay for",
|
||||
"Module name to use overlay for",
|
||||
)
|
||||
.optional(
|
||||
"as",
|
||||
@ -145,21 +145,21 @@ impl Command for OverlayAdd {
|
||||
Example {
|
||||
description: "Create an overlay from a module",
|
||||
example: r#"module spam { export def foo [] { "foo" } }
|
||||
overlay add spam
|
||||
overlay use spam
|
||||
foo"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Create an overlay with a prefix",
|
||||
example: r#"echo 'export def foo { "foo" }'
|
||||
overlay add --prefix spam
|
||||
overlay use --prefix spam
|
||||
spam foo"#,
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
description: "Create an overlay from a file",
|
||||
example: r#"echo 'export env FOO { "foo" }' | save spam.nu
|
||||
overlay add spam.nu
|
||||
overlay use spam.nu
|
||||
$env.FOO"#,
|
||||
result: None,
|
||||
},
|
||||
@ -175,6 +175,6 @@ mod test {
|
||||
fn test_examples() {
|
||||
use crate::test_examples;
|
||||
|
||||
test_examples(OverlayAdd {})
|
||||
test_examples(OverlayUse {})
|
||||
}
|
||||
}
|
@ -51,10 +51,10 @@ pub fn create_default_context() -> EngineState {
|
||||
If,
|
||||
Ignore,
|
||||
Overlay,
|
||||
OverlayAdd,
|
||||
OverlayUse,
|
||||
OverlayList,
|
||||
OverlayNew,
|
||||
OverlayRemove,
|
||||
OverlayHide,
|
||||
Let,
|
||||
Metadata,
|
||||
Module,
|
||||
|
@ -735,7 +735,7 @@ fn parse_script_with_nested_scripts_success() {
|
||||
r#"
|
||||
source ../foo.nu
|
||||
use lol_shell.nu
|
||||
overlay add ../lol/lol_shell.nu
|
||||
overlay use ../lol/lol_shell.nu
|
||||
"#,
|
||||
)])
|
||||
.with_files(vec![FileWithContentToBeTrimmed(
|
||||
|
@ -152,13 +152,13 @@ pub enum ParseError {
|
||||
)]
|
||||
CantRemoveLastOverlay(#[label = "this is the last overlay, can't remove it"] Span),
|
||||
|
||||
#[error("Cannot remove default overlay.")]
|
||||
#[error("Cannot hide default overlay.")]
|
||||
#[diagnostic(
|
||||
code(nu::parser::cant_remove_default_overlay),
|
||||
code(nu::parser::cant_hide_default_overlay),
|
||||
url(docsrs),
|
||||
help("'{0}' is a default overlay. Default overlays cannot be removed.")
|
||||
help("'{0}' is a default overlay. Default overlays cannot be hidden.")
|
||||
)]
|
||||
CantRemoveDefaultOverlay(String, #[label = "can't remove overlay"] Span),
|
||||
CantHideDefaultOverlay(String, #[label = "can't hide overlay"] Span),
|
||||
|
||||
#[error("Cannot add overlay.")]
|
||||
#[diagnostic(code(nu::parser::cant_add_overlay_help), url(docsrs), help("{0}"))]
|
||||
@ -345,7 +345,7 @@ impl ParseError {
|
||||
ParseError::ActiveOverlayNotFound(s) => *s,
|
||||
ParseError::OverlayPrefixMismatch(_, _, s) => *s,
|
||||
ParseError::CantRemoveLastOverlay(s) => *s,
|
||||
ParseError::CantRemoveDefaultOverlay(_, s) => *s,
|
||||
ParseError::CantHideDefaultOverlay(_, s) => *s,
|
||||
ParseError::CantAddOverlayHelp(_, s) => *s,
|
||||
ParseError::NotFound(s) => *s,
|
||||
ParseError::DuplicateCommandDef(s) => *s,
|
||||
|
@ -1823,8 +1823,8 @@ pub fn parse_overlay(
|
||||
let subcommand = working_set.get_span_contents(spans[1]);
|
||||
|
||||
match subcommand {
|
||||
b"add" => {
|
||||
return parse_overlay_add(working_set, spans, expand_aliases_denylist);
|
||||
b"use" => {
|
||||
return parse_overlay_use(working_set, spans, expand_aliases_denylist);
|
||||
}
|
||||
b"list" => {
|
||||
// TODO: Abstract this code blob, it's repeated all over the place:
|
||||
@ -1884,8 +1884,8 @@ pub fn parse_overlay(
|
||||
b"new" => {
|
||||
return parse_overlay_new(working_set, spans, expand_aliases_denylist);
|
||||
}
|
||||
b"remove" => {
|
||||
return parse_overlay_remove(working_set, spans, expand_aliases_denylist);
|
||||
b"hide" => {
|
||||
return parse_overlay_hide(working_set, spans, expand_aliases_denylist);
|
||||
}
|
||||
_ => { /* continue parsing overlay */ }
|
||||
}
|
||||
@ -2045,23 +2045,23 @@ pub fn parse_overlay_new(
|
||||
(pipeline, None)
|
||||
}
|
||||
|
||||
pub fn parse_overlay_add(
|
||||
pub fn parse_overlay_use(
|
||||
working_set: &mut StateWorkingSet,
|
||||
spans: &[Span],
|
||||
expand_aliases_denylist: &[usize],
|
||||
) -> (Pipeline, Option<ParseError>) {
|
||||
if spans.len() > 1 && working_set.get_span_contents(span(&spans[0..2])) != b"overlay add" {
|
||||
if spans.len() > 1 && working_set.get_span_contents(span(&spans[0..2])) != b"overlay use" {
|
||||
return (
|
||||
garbage_pipeline(spans),
|
||||
Some(ParseError::UnknownState(
|
||||
"internal error: Wrong call name for 'overlay add' command".into(),
|
||||
"internal error: Wrong call name for 'overlay use' command".into(),
|
||||
span(spans),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
// TODO: Allow full import pattern as argument (requires custom naming of module/overlay)
|
||||
let (call, call_span) = match working_set.find_decl(b"overlay add", &Type::Any) {
|
||||
let (call, call_span) = match working_set.find_decl(b"overlay use", &Type::Any) {
|
||||
Some(decl_id) => {
|
||||
let ParsedInternalCall {
|
||||
call,
|
||||
@ -2097,7 +2097,7 @@ pub fn parse_overlay_add(
|
||||
return (
|
||||
garbage_pipeline(spans),
|
||||
Some(ParseError::UnknownState(
|
||||
"internal error: 'overlay add' declaration not found".into(),
|
||||
"internal error: 'overlay use' declaration not found".into(),
|
||||
span(spans),
|
||||
)),
|
||||
)
|
||||
@ -2321,22 +2321,22 @@ pub fn parse_overlay_add(
|
||||
(pipeline, error)
|
||||
}
|
||||
|
||||
pub fn parse_overlay_remove(
|
||||
pub fn parse_overlay_hide(
|
||||
working_set: &mut StateWorkingSet,
|
||||
spans: &[Span],
|
||||
expand_aliases_denylist: &[usize],
|
||||
) -> (Pipeline, Option<ParseError>) {
|
||||
if spans.len() > 1 && working_set.get_span_contents(span(&spans[0..2])) != b"overlay remove" {
|
||||
if spans.len() > 1 && working_set.get_span_contents(span(&spans[0..2])) != b"overlay hide" {
|
||||
return (
|
||||
garbage_pipeline(spans),
|
||||
Some(ParseError::UnknownState(
|
||||
"internal error: Wrong call name for 'overlay remove' command".into(),
|
||||
"internal error: Wrong call name for 'overlay hide' command".into(),
|
||||
span(spans),
|
||||
)),
|
||||
);
|
||||
}
|
||||
|
||||
let call = match working_set.find_decl(b"overlay remove", &Type::Any) {
|
||||
let call = match working_set.find_decl(b"overlay hide", &Type::Any) {
|
||||
Some(decl_id) => {
|
||||
let ParsedInternalCall {
|
||||
call,
|
||||
@ -2372,7 +2372,7 @@ pub fn parse_overlay_remove(
|
||||
return (
|
||||
garbage_pipeline(spans),
|
||||
Some(ParseError::UnknownState(
|
||||
"internal error: 'overlay remove' declaration not found".into(),
|
||||
"internal error: 'overlay hide' declaration not found".into(),
|
||||
span(spans),
|
||||
)),
|
||||
)
|
||||
@ -2410,7 +2410,7 @@ pub fn parse_overlay_remove(
|
||||
if overlay_name == DEFAULT_OVERLAY_NAME {
|
||||
return (
|
||||
pipeline,
|
||||
Some(ParseError::CantRemoveDefaultOverlay(
|
||||
Some(ParseError::CantHideDefaultOverlay(
|
||||
overlay_name,
|
||||
overlay_name_span,
|
||||
)),
|
||||
|
@ -4,7 +4,7 @@ use nu_test_support::{nu, nu_repl_code, pipeline};
|
||||
fn add_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -19,8 +19,8 @@ fn add_overlay() {
|
||||
fn add_overlay_twice() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -35,7 +35,7 @@ fn add_overlay_twice() {
|
||||
fn add_prefixed_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"spam foo"#,
|
||||
];
|
||||
|
||||
@ -50,8 +50,8 @@ fn add_prefixed_overlay() {
|
||||
fn add_prefixed_overlay_twice() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"spam foo"#,
|
||||
];
|
||||
|
||||
@ -66,8 +66,8 @@ fn add_prefixed_overlay_twice() {
|
||||
fn add_prefixed_overlay_mismatch_1() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"overlay use spam"#,
|
||||
];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
@ -82,8 +82,8 @@ fn add_prefixed_overlay_mismatch_1() {
|
||||
fn add_prefixed_overlay_mismatch_2() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
@ -98,9 +98,9 @@ fn add_prefixed_overlay_mismatch_2() {
|
||||
fn prefixed_overlay_keeps_custom_decl() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"def bar [] { "bar" }"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bar"#,
|
||||
];
|
||||
|
||||
@ -115,7 +115,7 @@ fn prefixed_overlay_keeps_custom_decl() {
|
||||
fn add_overlay_env() {
|
||||
let inp = &[
|
||||
r#"module spam { export env FOO { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"$env.FOO"#,
|
||||
];
|
||||
|
||||
@ -130,7 +130,7 @@ fn add_overlay_env() {
|
||||
fn add_prefixed_overlay_env_no_prefix() {
|
||||
let inp = &[
|
||||
r#"module spam { export env FOO { "foo" } }"#,
|
||||
r#"overlay add --prefix spam"#,
|
||||
r#"overlay use --prefix spam"#,
|
||||
r#"$env.FOO"#,
|
||||
];
|
||||
|
||||
@ -143,7 +143,7 @@ fn add_prefixed_overlay_env_no_prefix() {
|
||||
|
||||
#[test]
|
||||
fn add_overlay_from_file_decl() {
|
||||
let inp = &[r#"overlay add samples/spam.nu"#, r#"foo"#];
|
||||
let inp = &[r#"overlay use samples/spam.nu"#, r#"foo"#];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
||||
@ -155,7 +155,7 @@ fn add_overlay_from_file_decl() {
|
||||
// This one tests that the `nu_repl()` loop works correctly
|
||||
#[test]
|
||||
fn add_overlay_from_file_decl_cd() {
|
||||
let inp = &[r#"cd samples"#, r#"overlay add spam.nu"#, r#"foo"#];
|
||||
let inp = &[r#"cd samples"#, r#"overlay use spam.nu"#, r#"foo"#];
|
||||
|
||||
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
||||
|
||||
@ -164,7 +164,7 @@ fn add_overlay_from_file_decl_cd() {
|
||||
|
||||
#[test]
|
||||
fn add_overlay_from_file_alias() {
|
||||
let inp = &[r#"overlay add samples/spam.nu"#, r#"bar"#];
|
||||
let inp = &[r#"overlay use samples/spam.nu"#, r#"bar"#];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
||||
@ -175,7 +175,7 @@ fn add_overlay_from_file_alias() {
|
||||
|
||||
#[test]
|
||||
fn add_overlay_from_file_env() {
|
||||
let inp = &[r#"overlay add samples/spam.nu"#, r#"$env.BAZ"#];
|
||||
let inp = &[r#"overlay use samples/spam.nu"#, r#"$env.BAZ"#];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
let actual_repl = nu!(cwd: "tests/overlays", nu_repl_code(inp));
|
||||
@ -188,7 +188,7 @@ fn add_overlay_from_file_env() {
|
||||
fn add_overlay_scoped() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"do { overlay add spam }"#,
|
||||
r#"do { overlay use spam }"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -206,9 +206,9 @@ fn add_overlay_scoped() {
|
||||
fn update_overlay_from_module() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"module spam { export def foo [] { "bar" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -223,9 +223,9 @@ fn update_overlay_from_module() {
|
||||
fn update_overlay_from_module_env() {
|
||||
let inp = &[
|
||||
r#"module spam { export env FOO { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"module spam { export env FOO { "bar" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"$env.FOO"#,
|
||||
];
|
||||
|
||||
@ -240,8 +240,8 @@ fn update_overlay_from_module_env() {
|
||||
fn remove_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -259,8 +259,8 @@ fn remove_overlay() {
|
||||
fn remove_last_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay remove"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay hide"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -278,8 +278,8 @@ fn remove_last_overlay() {
|
||||
fn remove_overlay_scoped() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"do { overlay remove spam }"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"do { overlay hide spam }"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -294,8 +294,8 @@ fn remove_overlay_scoped() {
|
||||
fn remove_overlay_env() {
|
||||
let inp = &[
|
||||
r#"module spam { export env FOO { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"$env.FOO"#,
|
||||
];
|
||||
|
||||
@ -310,8 +310,8 @@ fn remove_overlay_env() {
|
||||
fn remove_overlay_scoped_env() {
|
||||
let inp = &[
|
||||
r#"module spam { export env FOO { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"do { overlay remove spam }"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"do { overlay hide spam }"#,
|
||||
r#"$env.FOO"#,
|
||||
];
|
||||
|
||||
@ -337,7 +337,7 @@ fn list_default_overlay() {
|
||||
fn list_last_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay list | last"#,
|
||||
];
|
||||
|
||||
@ -352,7 +352,7 @@ fn list_last_overlay() {
|
||||
fn list_overlay_scoped() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"do { overlay list | last }"#,
|
||||
];
|
||||
|
||||
@ -366,9 +366,9 @@ fn list_overlay_scoped() {
|
||||
#[test]
|
||||
fn remove_overlay_discard_decl() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def bagr [] { "bagr" }"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -385,9 +385,9 @@ fn remove_overlay_discard_decl() {
|
||||
#[test]
|
||||
fn remove_overlay_discard_alias() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"alias bagr = "bagr""#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -404,9 +404,9 @@ fn remove_overlay_discard_alias() {
|
||||
#[test]
|
||||
fn remove_overlay_discard_env() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"let-env BAGR = `bagr`"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"$env.BAGR"#,
|
||||
];
|
||||
|
||||
@ -420,9 +420,9 @@ fn remove_overlay_discard_env() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_decl() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def bagr [] { "bagr" }"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -436,9 +436,9 @@ fn remove_overlay_keep_decl() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_alias() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"alias bagr = `bagr`"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -452,9 +452,9 @@ fn remove_overlay_keep_alias() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_env() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"let-env BAGR = `bagr`"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"$env.BAGR"#,
|
||||
];
|
||||
|
||||
@ -468,9 +468,9 @@ fn remove_overlay_keep_env() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_discard_overwritten_decl() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def foo [] { 'bar' }"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -487,9 +487,9 @@ fn remove_overlay_keep_discard_overwritten_decl() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_discard_overwritten_alias() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"alias bar = `baz`"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bar"#,
|
||||
];
|
||||
|
||||
@ -506,9 +506,9 @@ fn remove_overlay_keep_discard_overwritten_alias() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_discard_overwritten_env() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"let-env BAZ = `bagr`"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"$env.BAZ"#,
|
||||
];
|
||||
|
||||
@ -522,11 +522,11 @@ fn remove_overlay_keep_discard_overwritten_env() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_decl_in_latest_overlay() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def bagr [] { 'bagr' }"#,
|
||||
r#"module eggs { }"#,
|
||||
r#"overlay add eggs"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay use eggs"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -540,11 +540,11 @@ fn remove_overlay_keep_decl_in_latest_overlay() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_alias_in_latest_overlay() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"alias bagr = `bagr`"#,
|
||||
r#"module eggs { }"#,
|
||||
r#"overlay add eggs"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay use eggs"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"bagr"#,
|
||||
];
|
||||
|
||||
@ -558,11 +558,11 @@ fn remove_overlay_keep_alias_in_latest_overlay() {
|
||||
#[test]
|
||||
fn remove_overlay_keep_env_in_latest_overlay() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"let-env BAGR = `bagr`"#,
|
||||
r#"module eggs { }"#,
|
||||
r#"overlay add eggs"#,
|
||||
r#"overlay remove --keep-custom spam"#,
|
||||
r#"overlay use eggs"#,
|
||||
r#"overlay hide --keep-custom spam"#,
|
||||
r#"$env.BAGR"#,
|
||||
];
|
||||
|
||||
@ -576,10 +576,10 @@ fn remove_overlay_keep_env_in_latest_overlay() {
|
||||
#[test]
|
||||
fn preserve_overrides() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def foo [] { "new-foo" }"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -593,10 +593,10 @@ fn preserve_overrides() {
|
||||
#[test]
|
||||
fn reset_overrides() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"def foo [] { "new-foo" }"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay add samples/spam.nu"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"overlay use samples/spam.nu"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -623,7 +623,7 @@ fn overlay_keep_pwd() {
|
||||
let inp = &[
|
||||
r#"overlay new spam"#,
|
||||
r#"cd samples"#,
|
||||
r#"overlay remove --keep-env [ PWD ] spam"#,
|
||||
r#"overlay hide --keep-env [ PWD ] spam"#,
|
||||
r#"$env.PWD | path basename"#,
|
||||
];
|
||||
|
||||
@ -636,7 +636,7 @@ fn overlay_keep_pwd() {
|
||||
|
||||
#[test]
|
||||
fn overlay_wrong_rename_type() {
|
||||
let inp = &[r#"module spam {}"#, r#"overlay add spam as { echo foo }"#];
|
||||
let inp = &[r#"module spam {}"#, r#"overlay use spam as { echo foo }"#];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
|
||||
@ -647,7 +647,7 @@ fn overlay_wrong_rename_type() {
|
||||
fn overlay_add_renamed() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam as eggs --prefix"#,
|
||||
r#"overlay use spam as eggs --prefix"#,
|
||||
r#"eggs foo"#,
|
||||
];
|
||||
|
||||
@ -661,7 +661,7 @@ fn overlay_add_renamed() {
|
||||
#[test]
|
||||
fn overlay_add_renamed_from_file() {
|
||||
let inp = &[
|
||||
r#"overlay add samples/spam.nu as eggs --prefix"#,
|
||||
r#"overlay use samples/spam.nu as eggs --prefix"#,
|
||||
r#"eggs foo"#,
|
||||
];
|
||||
|
||||
@ -676,9 +676,9 @@ fn overlay_add_renamed_from_file() {
|
||||
fn overlay_cant_rename_existing_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam"#,
|
||||
r#"overlay remove spam"#,
|
||||
r#"overlay add spam as eggs"#,
|
||||
r#"overlay use spam"#,
|
||||
r#"overlay hide spam"#,
|
||||
r#"overlay use spam as eggs"#,
|
||||
];
|
||||
|
||||
let actual = nu!(cwd: "tests/overlays", pipeline(&inp.join("; ")));
|
||||
@ -692,8 +692,8 @@ fn overlay_cant_rename_existing_overlay() {
|
||||
fn overlay_can_add_renamed_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam as eggs --prefix"#,
|
||||
r#"overlay add spam --prefix"#,
|
||||
r#"overlay use spam as eggs --prefix"#,
|
||||
r#"overlay use spam --prefix"#,
|
||||
r#"(spam foo) + (eggs foo)"#,
|
||||
];
|
||||
|
||||
@ -708,8 +708,8 @@ fn overlay_can_add_renamed_overlay() {
|
||||
fn overlay_remove_renamed_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam as eggs"#,
|
||||
r#"overlay remove eggs"#,
|
||||
r#"overlay use spam as eggs"#,
|
||||
r#"overlay hide eggs"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
@ -724,9 +724,9 @@ fn overlay_remove_renamed_overlay() {
|
||||
fn overlay_remove_and_add_renamed_overlay() {
|
||||
let inp = &[
|
||||
r#"module spam { export def foo [] { "foo" } }"#,
|
||||
r#"overlay add spam as eggs"#,
|
||||
r#"overlay remove eggs"#,
|
||||
r#"overlay add eggs"#,
|
||||
r#"overlay use spam as eggs"#,
|
||||
r#"overlay hide eggs"#,
|
||||
r#"overlay use eggs"#,
|
||||
r#"foo"#,
|
||||
];
|
||||
|
||||
|
@ -58,7 +58,7 @@ fn parse_file_relative_to_parsed_file() {
|
||||
r#"
|
||||
source ../../foo.nu
|
||||
use ../lol_shell.nu
|
||||
overlay add ../../lol/lol_shell.nu
|
||||
overlay use ../../lol/lol_shell.nu
|
||||
|
||||
$'($env.FOO) (lol_shell ls) (ls)'
|
||||
"#,
|
||||
|
Loading…
Reference in New Issue
Block a user