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:
WindSoilder
2022-08-21 22:27:56 +08:00
committed by GitHub
parent c5ca839294
commit 9c4bbe3c63
10 changed files with 138 additions and 138 deletions

View File

@ -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,
},
]

View File

@ -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(),

View File

@ -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;

View File

@ -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 {})
}
}

View File

@ -51,10 +51,10 @@ pub fn create_default_context() -> EngineState {
If,
Ignore,
Overlay,
OverlayAdd,
OverlayUse,
OverlayList,
OverlayNew,
OverlayRemove,
OverlayHide,
Let,
Metadata,
Module,