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::{PipelineData, ShellError, Signature};
use nu_protocol::{Category, PipelineData, ShellError, Signature};
#[derive(Clone)]
pub struct From;
@ -15,7 +15,7 @@ impl Command for From {
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("from")
Signature::build("from").category(Category::Formats)
}
fn run(

View File

@ -3,7 +3,7 @@ use super::delimited::from_delimited_data;
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};
use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value};
#[derive(Clone)]
pub struct FromCsv;
@ -26,6 +26,7 @@ impl Command for FromCsv {
"don't treat the first row as column names",
Some('n'),
)
.category(Category::Formats)
}
fn usage(&self) -> &str {

View File

@ -4,6 +4,7 @@ use indexmap::map::IndexMap;
use nu_engine::CallExt;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::Category;
use nu_protocol::Config;
use nu_protocol::{
Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value,
@ -20,12 +21,14 @@ impl Command for FromEml {
}
fn signature(&self) -> Signature {
Signature::build("from eml").named(
"preview-body",
SyntaxShape::Int,
"How many bytes of the body to preview",
Some('b'),
)
Signature::build("from eml")
.named(
"preview-body",
SyntaxShape::Int,
"How many bytes of the body to preview",
Some('b'),
)
.category(Category::Formats)
}
fn usage(&self) -> &str {

View File

@ -1,8 +1,8 @@
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, Signature,
Span, Value,
Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError,
Signature, Span, Value,
};
#[derive(Clone)]
@ -18,11 +18,9 @@ impl Command for FromJson {
}
fn signature(&self) -> nu_protocol::Signature {
Signature::build("from json").switch(
"objects",
"treat each line as a separate value",
Some('o'),
)
Signature::build("from json")
.switch("objects", "treat each line as a separate value", Some('o'))
.category(Category::Formats)
}
fn examples(&self) -> Vec<Example> {

View File

@ -2,7 +2,7 @@ use super::delimited::from_delimited_data;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{Config, PipelineData, ShellError, Signature};
use nu_protocol::{Category, Config, PipelineData, ShellError, Signature};
#[derive(Clone)]
pub struct FromTsv;
@ -13,11 +13,13 @@ impl Command for FromTsv {
}
fn signature(&self) -> Signature {
Signature::build("from csv").switch(
"noheaders",
"don't treat the first row as column names",
Some('n'),
)
Signature::build("from csv")
.switch(
"noheaders",
"don't treat the first row as column names",
Some('n'),
)
.category(Category::Formats)
}
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::{Config, Example, PipelineData, ShellError, Signature, Span, Value};
use nu_protocol::{Category, Config, Example, PipelineData, ShellError, Signature, Span, Value};
#[derive(Clone)]
pub struct FromUrl;
@ -11,7 +11,7 @@ impl Command for FromUrl {
}
fn signature(&self) -> Signature {
Signature::build("from url")
Signature::build("from url").category(Category::Formats)
}
fn usage(&self) -> &str {

View File

@ -2,7 +2,8 @@ use itertools::Itertools;
use nu_protocol::ast::Call;
use nu_protocol::engine::{Command, EngineState, Stack};
use nu_protocol::{
Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Spanned, Value,
Category, Config, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span,
Spanned, Value,
};
use serde::de::Deserialize;
use std::collections::HashMap;
@ -16,7 +17,7 @@ impl Command for FromYaml {
}
fn signature(&self) -> Signature {
Signature::build("from yaml")
Signature::build("from yaml").category(Category::Formats)
}
fn usage(&self) -> &str {
@ -84,7 +85,7 @@ impl Command for FromYml {
}
fn signature(&self) -> Signature {
Signature::build("from yml")
Signature::build("from yml").category(Category::Formats)
}
fn usage(&self) -> &str {