Category option for signature (#343)

* category option for signature

* category option for signature

* column description for $scope
This commit is contained in:
Fernando Herrera
2021-11-17 04:22:37 +00:00
committed by GitHub
parent 6fbe02eb21
commit b35914bd17
118 changed files with 739 additions and 335 deletions

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -11,7 +11,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math abs")
Signature::build("math abs").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math avg")
Signature::build("math avg").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -11,7 +11,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math ceil")
Signature::build("math ceil").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -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 MathCommand {
}
fn signature(&self) -> Signature {
Signature::build("math")
Signature::build("math").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
};
#[derive(Clone)]
@ -18,11 +18,13 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math eval").optional(
"math expression",
SyntaxShape::String,
"the math expression to evaluate",
)
Signature::build("math eval")
.optional(
"math expression",
SyntaxShape::String,
"the math expression to evaluate",
)
.category(Category::Math)
}
fn run(

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -11,7 +11,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math floor")
Signature::build("math floor").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math max")
Signature::build("math max").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::avg::average;
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math median")
Signature::build("math median").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math min")
Signature::build("math min").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -1,7 +1,7 @@
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
use std::cmp::Ordering;
#[derive(Clone)]
@ -36,7 +36,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math mode")
Signature::build("math mode").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math product")
Signature::build("math product").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -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, Span, SyntaxShape, Value};
use nu_protocol::{
Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value,
};
#[derive(Clone)]
pub struct SubCommand;
@ -12,12 +14,14 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math round").named(
"precision",
SyntaxShape::Number,
"digits of precision",
Some('p'),
)
Signature::build("math round")
.named(
"precision",
SyntaxShape::Number,
"digits of precision",
Some('p'),
)
.category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -1,6 +1,6 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -11,7 +11,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math sqrt")
Signature::build("math sqrt").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use super::variance::compute_variance as variance;
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,11 +13,9 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math stddev").switch(
"sample",
"calculate sample standard deviation",
Some('s'),
)
Signature::build("math stddev")
.switch("sample", "calculate sample standard deviation", Some('s'))
.category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,7 @@ use crate::math::reducers::{reducer_for, Reduce};
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -13,7 +13,7 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math sum")
Signature::build("math sum").category(Category::Math)
}
fn usage(&self) -> &str {

View File

@ -1,7 +1,7 @@
use crate::math::utils::run_with_function;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct SubCommand;
@ -12,7 +12,9 @@ impl Command for SubCommand {
}
fn signature(&self) -> Signature {
Signature::build("math variance").switch("sample", "calculate sample variance", Some('s'))
Signature::build("math variance")
.switch("sample", "calculate sample variance", Some('s'))
.category(Category::Math)
}
fn usage(&self) -> &str {