mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:26:22 +02:00
Category option for signature (#343)
* category option for signature * category option for signature * column description for $scope
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Alias;
|
||||
@ -22,6 +22,7 @@ impl Command for Alias {
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
|
||||
"equals sign followed by value",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Def;
|
||||
@ -23,6 +23,7 @@ impl Command for Def {
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"body of the definition",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_engine::{eval_block, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape, Value};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape, Value};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Do;
|
||||
@ -24,6 +24,7 @@ impl Command for Do {
|
||||
"the block to run",
|
||||
)
|
||||
.rest("rest", SyntaxShape::Any, "the parameter(s) for the block")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,7 +1,9 @@
|
||||
use nu_engine::CallExt;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{Example, PipelineData, ShellError, Signature, SyntaxShape, Value, ValueStream};
|
||||
use nu_protocol::{
|
||||
Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value, ValueStream,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Echo;
|
||||
@ -16,7 +18,9 @@ impl Command for Echo {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("echo").rest("rest", SyntaxShape::Any, "the values to echo")
|
||||
Signature::build("echo")
|
||||
.rest("rest", SyntaxShape::Any, "the values to echo")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -2,7 +2,7 @@ use nu_engine::get_full_help;
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
IntoPipelineData, PipelineData, Signature, Value,
|
||||
Category, IntoPipelineData, PipelineData, Signature, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -14,7 +14,7 @@ impl Command for ExportCommand {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("export")
|
||||
Signature::build("export").category(Category::Core)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExportDef;
|
||||
@ -23,6 +23,7 @@ impl Command for ExportDef {
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"body of the definition",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ExportEnv;
|
||||
@ -26,6 +26,7 @@ impl Command for ExportEnv {
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"body of the environment variable definition",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -2,7 +2,8 @@ use nu_engine::{eval_block, eval_expression};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{
|
||||
Example, IntoInterruptiblePipelineData, PipelineData, Signature, Span, SyntaxShape, Value,
|
||||
Category, Example, IntoInterruptiblePipelineData, PipelineData, Signature, Span, SyntaxShape,
|
||||
Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
@ -35,6 +36,7 @@ impl Command for For {
|
||||
"the block to run",
|
||||
)
|
||||
.creates_scope()
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,8 +1,8 @@
|
||||
use nu_protocol::{
|
||||
ast::Call,
|
||||
engine::{Command, EngineState, Stack},
|
||||
span, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError,
|
||||
Signature, Spanned, SyntaxShape, Value,
|
||||
span, Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData,
|
||||
ShellError, Signature, Spanned, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
use nu_engine::{get_full_help, CallExt};
|
||||
@ -28,6 +28,7 @@ impl Command for Help {
|
||||
"string to find in command usage",
|
||||
Some('f'),
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
@ -107,6 +108,12 @@ fn help(
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("category".into());
|
||||
vals.push(Value::String {
|
||||
val: cmd.0.category.to_string(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("usage".into());
|
||||
vals.push(Value::String { val: c, span: head });
|
||||
|
||||
@ -144,6 +151,12 @@ fn help(
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("category".into());
|
||||
vals.push(Value::String {
|
||||
val: cmd.0.category.to_string(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("usage".into());
|
||||
vals.push(Value::String { val: c, span: head });
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Hide;
|
||||
@ -10,12 +10,14 @@ impl Command for Hide {
|
||||
"hide"
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
"Hide definitions in the current scope"
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("hide")
|
||||
.required("pattern", SyntaxShape::String, "import pattern")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("hide").required("pattern", SyntaxShape::String, "import pattern")
|
||||
fn usage(&self) -> &str {
|
||||
"Hide definitions in the current scope"
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,7 +1,9 @@
|
||||
use nu_engine::{eval_block, eval_expression};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value};
|
||||
use nu_protocol::{
|
||||
Category, IntoPipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value,
|
||||
};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct If;
|
||||
@ -24,6 +26,7 @@ impl Command for If {
|
||||
SyntaxShape::Keyword(b"else".to_vec(), Box::new(SyntaxShape::Expression)),
|
||||
"optional else followed by else block",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_engine::eval_expression;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Let;
|
||||
@ -23,6 +23,7 @@ impl Command for Let {
|
||||
SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::Expression)),
|
||||
"equals sign followed by value",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Module;
|
||||
@ -22,6 +22,7 @@ impl Command for Module {
|
||||
SyntaxShape::Block(Some(vec![])),
|
||||
"body of the module",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,6 +1,6 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, Signature, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Register;
|
||||
@ -15,11 +15,13 @@ impl Command for Register {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("register").required(
|
||||
"plugin",
|
||||
SyntaxShape::Filepath,
|
||||
"location of bin for plugin",
|
||||
)
|
||||
Signature::build("register")
|
||||
.required(
|
||||
"plugin",
|
||||
SyntaxShape::Filepath,
|
||||
"location of bin for plugin",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_engine::{eval_block, CallExt};
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape};
|
||||
|
||||
/// Source a file for environment variables.
|
||||
#[derive(Clone)]
|
||||
@ -13,11 +13,13 @@ impl Command for Source {
|
||||
}
|
||||
|
||||
fn signature(&self) -> Signature {
|
||||
Signature::build("source").required(
|
||||
"filename",
|
||||
SyntaxShape::Filepath,
|
||||
"the filepath to the script file to source",
|
||||
)
|
||||
Signature::build("source")
|
||||
.required(
|
||||
"filename",
|
||||
SyntaxShape::Filepath,
|
||||
"the filepath to the script file to source",
|
||||
)
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn usage(&self) -> &str {
|
||||
|
@ -1,7 +1,7 @@
|
||||
use nu_engine::eval_block;
|
||||
use nu_protocol::ast::{Call, Expr, Expression, ImportPatternMember};
|
||||
use nu_protocol::engine::{Command, EngineState, Stack};
|
||||
use nu_protocol::{PipelineData, ShellError, Signature, Span, SyntaxShape};
|
||||
use nu_protocol::{Category, PipelineData, ShellError, Signature, Span, SyntaxShape};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Use;
|
||||
@ -16,7 +16,9 @@ impl Command for Use {
|
||||
}
|
||||
|
||||
fn signature(&self) -> nu_protocol::Signature {
|
||||
Signature::build("use").rest("pattern", SyntaxShape::String, "import pattern parts")
|
||||
Signature::build("use")
|
||||
.rest("pattern", SyntaxShape::String, "import pattern parts")
|
||||
.category(Category::Core)
|
||||
}
|
||||
|
||||
fn run(
|
||||
|
Reference in New Issue
Block a user