diff --git a/crates/nu-command/src/conversions/into/binary.rs b/crates/nu-command/src/conversions/into/binary.rs index b0eecf0139..dffed7543c 100644 --- a/crates/nu-command/src/conversions/into/binary.rs +++ b/crates/nu-command/src/conversions/into/binary.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, - Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -14,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("into binary").rest( - "rest", - SyntaxShape::CellPath, - "column paths to convert to binary (for table input)", - ) + Signature::build("into binary") + .rest( + "rest", + SyntaxShape::CellPath, + "column paths to convert to binary (for table input)", + ) + .category(Category::Conversions) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/conversions/into/command.rs b/crates/nu-command/src/conversions/into/command.rs index 6054010580..9fa1ec600d 100644 --- a/crates/nu-command/src/conversions/into/command.rs +++ b/crates/nu-command/src/conversions/into/command.rs @@ -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 Into { } fn signature(&self) -> Signature { - Signature::build("into") + Signature::build("into").category(Category::Conversions) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/conversions/into/filesize.rs b/crates/nu-command/src/conversions/into/filesize.rs index 6336c72196..795dff7ee0 100644 --- a/crates/nu-command/src/conversions/into/filesize.rs +++ b/crates/nu-command/src/conversions/into/filesize.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, - Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -14,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("into filesize").rest( - "rest", - SyntaxShape::CellPath, - "column paths to convert to filesize (for table input)", - ) + Signature::build("into filesize") + .rest( + "rest", + SyntaxShape::CellPath, + "column paths to convert to filesize (for table input)", + ) + .category(Category::Conversions) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/conversions/into/int.rs b/crates/nu-command/src/conversions/into/int.rs index 8c0914c786..e6185dabbd 100644 --- a/crates/nu-command/src/conversions/into/int.rs +++ b/crates/nu-command/src/conversions/into/int.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, - Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -14,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("into int").rest( - "rest", - SyntaxShape::CellPath, - "column paths to convert to int (for table input)", - ) + Signature::build("into int") + .rest( + "rest", + SyntaxShape::CellPath, + "column paths to convert to int (for table input)", + ) + .category(Category::Conversions) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/conversions/into/string.rs b/crates/nu-command/src/conversions/into/string.rs index 318d335346..842edc6daa 100644 --- a/crates/nu-command/src/conversions/into/string.rs +++ b/crates/nu-command/src/conversions/into/string.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::{Call, CellPath}, engine::{Command, EngineState, Stack}, - Config, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Config, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, }; // TODO num_format::SystemLocale once platform-specific dependencies are stable (see Cargo.toml) @@ -29,6 +29,7 @@ impl Command for SubCommand { "decimal digits to which to round", Some('d'), ) + .category(Category::Conversions) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/core_commands/alias.rs b/crates/nu-command/src/core_commands/alias.rs index ae09d52286..158a3e9de6 100644 --- a/crates/nu-command/src/core_commands/alias.rs +++ b/crates/nu-command/src/core_commands/alias.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/def.rs b/crates/nu-command/src/core_commands/def.rs index 6632c1e736..63d07c4225 100644 --- a/crates/nu-command/src/core_commands/def.rs +++ b/crates/nu-command/src/core_commands/def.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/do_.rs b/crates/nu-command/src/core_commands/do_.rs index 92ac299f71..f85f347466 100644 --- a/crates/nu-command/src/core_commands/do_.rs +++ b/crates/nu-command/src/core_commands/do_.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/echo.rs b/crates/nu-command/src/core_commands/echo.rs index be7f231fb9..06a1ff1ed4 100644 --- a/crates/nu-command/src/core_commands/echo.rs +++ b/crates/nu-command/src/core_commands/echo.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/export.rs b/crates/nu-command/src/core_commands/export.rs index 704b7d59bd..93e3f91cda 100644 --- a/crates/nu-command/src/core_commands/export.rs +++ b/crates/nu-command/src/core_commands/export.rs @@ -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 { diff --git a/crates/nu-command/src/core_commands/export_def.rs b/crates/nu-command/src/core_commands/export_def.rs index e0da0ad070..79d7c2bff7 100644 --- a/crates/nu-command/src/core_commands/export_def.rs +++ b/crates/nu-command/src/core_commands/export_def.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/export_env.rs b/crates/nu-command/src/core_commands/export_env.rs index 1cfb1d009a..261a97b3ab 100644 --- a/crates/nu-command/src/core_commands/export_env.rs +++ b/crates/nu-command/src/core_commands/export_env.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/for_.rs b/crates/nu-command/src/core_commands/for_.rs index 6435b76967..13343db25a 100644 --- a/crates/nu-command/src/core_commands/for_.rs +++ b/crates/nu-command/src/core_commands/for_.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/help.rs b/crates/nu-command/src/core_commands/help.rs index 534a369788..bad246f870 100644 --- a/crates/nu-command/src/core_commands/help.rs +++ b/crates/nu-command/src/core_commands/help.rs @@ -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 }); diff --git a/crates/nu-command/src/core_commands/hide.rs b/crates/nu-command/src/core_commands/hide.rs index 8d28509efa..700280e663 100644 --- a/crates/nu-command/src/core_commands/hide.rs +++ b/crates/nu-command/src/core_commands/hide.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/if_.rs b/crates/nu-command/src/core_commands/if_.rs index dc3e8c7adf..9de1bb1769 100644 --- a/crates/nu-command/src/core_commands/if_.rs +++ b/crates/nu-command/src/core_commands/if_.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/let_.rs b/crates/nu-command/src/core_commands/let_.rs index 5cd254a069..5742f1a233 100644 --- a/crates/nu-command/src/core_commands/let_.rs +++ b/crates/nu-command/src/core_commands/let_.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/module.rs b/crates/nu-command/src/core_commands/module.rs index 3f8f12105d..fbdc067295 100644 --- a/crates/nu-command/src/core_commands/module.rs +++ b/crates/nu-command/src/core_commands/module.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/register.rs b/crates/nu-command/src/core_commands/register.rs index c5fee5a22d..e60e2bd3ba 100644 --- a/crates/nu-command/src/core_commands/register.rs +++ b/crates/nu-command/src/core_commands/register.rs @@ -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( diff --git a/crates/nu-command/src/core_commands/source.rs b/crates/nu-command/src/core_commands/source.rs index d60f330d34..b4626e5e38 100644 --- a/crates/nu-command/src/core_commands/source.rs +++ b/crates/nu-command/src/core_commands/source.rs @@ -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 { diff --git a/crates/nu-command/src/core_commands/use_.rs b/crates/nu-command/src/core_commands/use_.rs index 06b60df5ae..368af53ea3 100644 --- a/crates/nu-command/src/core_commands/use_.rs +++ b/crates/nu-command/src/core_commands/use_.rs @@ -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( diff --git a/crates/nu-command/src/date/command.rs b/crates/nu-command/src/date/command.rs index 3206b3b7c2..86329ceb04 100644 --- a/crates/nu-command/src/date/command.rs +++ b/crates/nu-command/src/date/command.rs @@ -2,7 +2,7 @@ use nu_engine::get_full_help; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - IntoPipelineData, PipelineData, ShellError, Signature, Value, + Category, IntoPipelineData, PipelineData, ShellError, Signature, Value, }; #[derive(Clone)] @@ -14,7 +14,7 @@ impl Command for Date { } fn signature(&self) -> Signature { - Signature::build("date") + Signature::build("date").category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/format.rs b/crates/nu-command/src/date/format.rs index abee6653d4..33e14af106 100644 --- a/crates/nu-command/src/date/format.rs +++ b/crates/nu-command/src/date/format.rs @@ -3,7 +3,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Example, PipelineData, Signature, Span, Spanned, SyntaxShape, Value, + Category, Example, PipelineData, Signature, Span, Spanned, SyntaxShape, Value, }; use super::utils::{parse_date_from_string, unsupported_input_error}; @@ -17,11 +17,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("date format").required( - "format string", - SyntaxShape::String, - "the desired date format", - ) + Signature::build("date format") + .required( + "format string", + SyntaxShape::String, + "the desired date format", + ) + .category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/humanize.rs b/crates/nu-command/src/date/humanize.rs index 52abbd6538..6f4087b832 100644 --- a/crates/nu-command/src/date/humanize.rs +++ b/crates/nu-command/src/date/humanize.rs @@ -3,7 +3,7 @@ use chrono::{DateTime, FixedOffset, Local}; use chrono_humanize::HumanTime; 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("date humanize") + Signature::build("date humanize").category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/list_timezone.rs b/crates/nu-command/src/date/list_timezone.rs index 7e4ba8ee77..1114398174 100644 --- a/crates/nu-command/src/date/list_timezone.rs +++ b/crates/nu-command/src/date/list_timezone.rs @@ -1,7 +1,7 @@ use chrono_tz::TZ_VARIANTS; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoInterruptiblePipelineData, PipelineData, Signature, Value}; +use nu_protocol::{Category, IntoInterruptiblePipelineData, PipelineData, Signature, Value}; #[derive(Clone)] pub struct SubCommand; @@ -12,7 +12,7 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("date list-timezone") + Signature::build("date list-timezone").category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/now.rs b/crates/nu-command/src/date/now.rs index dbd0f081f3..4069938338 100644 --- a/crates/nu-command/src/date/now.rs +++ b/crates/nu-command/src/date/now.rs @@ -1,7 +1,7 @@ use chrono::Local; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, Value}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, Value}; #[derive(Clone)] pub struct SubCommand; @@ -11,7 +11,7 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("date now") + Signature::build("date now").category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/to_table.rs b/crates/nu-command/src/date/to_table.rs index 91bd59af4a..f518d010dc 100644 --- a/crates/nu-command/src/date/to_table.rs +++ b/crates/nu-command/src/date/to_table.rs @@ -2,7 +2,7 @@ use crate::date::utils::{parse_date_from_string, unsupported_input_error}; use chrono::{DateTime, Datelike, FixedOffset, Local, Timelike}; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Example, PipelineData, Signature, Span, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, Span, Value}; #[derive(Clone)] pub struct SubCommand; @@ -13,7 +13,7 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("date to-table") + Signature::build("date to-table").category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/date/to_timezone.rs b/crates/nu-command/src/date/to_timezone.rs index c00f4711e1..593211ffd5 100644 --- a/crates/nu-command/src/date/to_timezone.rs +++ b/crates/nu-command/src/date/to_timezone.rs @@ -5,7 +5,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, }; use chrono::{FixedOffset, TimeZone}; @@ -19,11 +19,9 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("date to-timezone").required( - "time zone", - SyntaxShape::String, - "time zone description", - ) + Signature::build("date to-timezone") + .required("time zone", SyntaxShape::String, "time zone description") + .category(Category::Date) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/env/let_env.rs b/crates/nu-command/src/env/let_env.rs index b67ebac1c7..201b0e6059 100644 --- a/crates/nu-command/src/env/let_env.rs +++ b/crates/nu-command/src/env/let_env.rs @@ -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 LetEnv; @@ -23,6 +23,7 @@ impl Command for LetEnv { SyntaxShape::Keyword(b"=".to_vec(), Box::new(SyntaxShape::String)), "equals sign followed by value", ) + .category(Category::Env) } fn run( diff --git a/crates/nu-command/src/env/with_env.rs b/crates/nu-command/src/env/with_env.rs index 8d5e18c07e..3f9b3aeece 100644 --- a/crates/nu-command/src/env/with_env.rs +++ b/crates/nu-command/src/env/with_env.rs @@ -7,7 +7,7 @@ use nu_engine::{eval_block, CallExt}; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Example, PipelineData, ShellError, Signature, SyntaxShape, Value, + Category, Example, PipelineData, ShellError, Signature, SyntaxShape, Value, }; #[derive(Clone)] @@ -30,6 +30,7 @@ impl Command for WithEnv { SyntaxShape::Block(Some(vec![SyntaxShape::Any])), "the block to run once the variable is set", ) + .category(Category::Env) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/experimental/git.rs b/crates/nu-command/src/experimental/git.rs index b3939116d6..ab3843133f 100644 --- a/crates/nu-command/src/experimental/git.rs +++ b/crates/nu-command/src/experimental/git.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, Value}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, Value}; #[derive(Clone)] pub struct Git; @@ -15,7 +15,7 @@ impl Command for Git { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("git") + Signature::build("git").category(Category::Experimental) } fn run( diff --git a/crates/nu-command/src/experimental/git_checkout.rs b/crates/nu-command/src/experimental/git_checkout.rs index ba55ae6f30..ba3834e225 100644 --- a/crates/nu-command/src/experimental/git_checkout.rs +++ b/crates/nu-command/src/experimental/git_checkout.rs @@ -1,7 +1,7 @@ use nu_engine::eval_expression; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, SyntaxShape, Value}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, SyntaxShape, Value}; #[derive(Clone)] pub struct GitCheckout; @@ -16,11 +16,13 @@ impl Command for GitCheckout { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("git checkout").required( - "branch", - SyntaxShape::Custom(Box::new(SyntaxShape::String), "list-git-branches".into()), - "the branch to checkout", - ) + Signature::build("git checkout") + .required( + "branch", + SyntaxShape::Custom(Box::new(SyntaxShape::String), "list-git-branches".into()), + "the branch to checkout", + ) + .category(Category::Experimental) } fn run( diff --git a/crates/nu-command/src/experimental/list_git_branches.rs b/crates/nu-command/src/experimental/list_git_branches.rs index bde67c0179..9a2fed5152 100644 --- a/crates/nu-command/src/experimental/list_git_branches.rs +++ b/crates/nu-command/src/experimental/list_git_branches.rs @@ -7,6 +7,7 @@ use nu_protocol::ast::Call; use nu_protocol::engine::Command; use nu_protocol::engine::EngineState; use nu_protocol::engine::Stack; +use nu_protocol::Category; use nu_protocol::IntoInterruptiblePipelineData; use nu_protocol::PipelineData; use nu_protocol::{Signature, Value}; @@ -25,7 +26,7 @@ impl Command for ListGitBranches { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("list-git-branches") + Signature::build("list-git-branches").category(Category::Experimental) } fn run( diff --git a/crates/nu-command/src/filesystem/cd.rs b/crates/nu-command/src/filesystem/cd.rs index 215ef38b61..ea6a00bedb 100644 --- a/crates/nu-command/src/filesystem/cd.rs +++ b/crates/nu-command/src/filesystem/cd.rs @@ -1,7 +1,7 @@ use nu_engine::CallExt; 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 Cd; @@ -16,7 +16,9 @@ impl Command for Cd { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("cd").optional("path", SyntaxShape::Filepath, "the path to change to") + Signature::build("cd") + .optional("path", SyntaxShape::Filepath, "the path to change to") + .category(Category::FileSystem) } fn run( diff --git a/crates/nu-command/src/filesystem/cp.rs b/crates/nu-command/src/filesystem/cp.rs index a553a84268..6f6b4f7d4f 100644 --- a/crates/nu-command/src/filesystem/cp.rs +++ b/crates/nu-command/src/filesystem/cp.rs @@ -6,7 +6,7 @@ use nu_engine::CallExt; use nu_path::canonicalize_with; 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}; use crate::filesystem::util::FileStructure; @@ -34,6 +34,7 @@ impl Command for Cp { ) .switch("force", "suppress error when no file", Some('f')) .switch("interactive", "ask user to confirm action", Some('i')) + .category(Category::FileSystem) } fn run( diff --git a/crates/nu-command/src/filesystem/ls.rs b/crates/nu-command/src/filesystem/ls.rs index 3dfc6975fa..dbf16057ba 100644 --- a/crates/nu-command/src/filesystem/ls.rs +++ b/crates/nu-command/src/filesystem/ls.rs @@ -3,7 +3,9 @@ use lscolors::{LsColors, Style}; use nu_engine::eval_expression; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoInterruptiblePipelineData, PipelineData, Signature, SyntaxShape, Value}; +use nu_protocol::{ + Category, IntoInterruptiblePipelineData, PipelineData, Signature, SyntaxShape, Value, +}; #[derive(Clone)] pub struct Ls; @@ -19,11 +21,13 @@ impl Command for Ls { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("ls").optional( - "pattern", - SyntaxShape::GlobPattern, - "the glob pattern to use", - ) + Signature::build("ls") + .optional( + "pattern", + SyntaxShape::GlobPattern, + "the glob pattern to use", + ) + .category(Category::FileSystem) } fn run( diff --git a/crates/nu-command/src/filesystem/mkdir.rs b/crates/nu-command/src/filesystem/mkdir.rs index df0beaa807..741dff715b 100644 --- a/crates/nu-command/src/filesystem/mkdir.rs +++ b/crates/nu-command/src/filesystem/mkdir.rs @@ -5,7 +5,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value, + Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, SyntaxShape, + Value, }; #[derive(Clone)] @@ -24,6 +25,7 @@ impl Command for Mkdir { "the name(s) of the path(s) to create", ) .switch("show-created-paths", "show the path(s) created.", Some('s')) + .category(Category::FileSystem) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filesystem/mv.rs b/crates/nu-command/src/filesystem/mv.rs index fe5262720b..777ac231bb 100644 --- a/crates/nu-command/src/filesystem/mv.rs +++ b/crates/nu-command/src/filesystem/mv.rs @@ -5,7 +5,7 @@ use super::util::get_interactive_confirmation; use nu_engine::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}; #[derive(Clone)] pub struct Mv; @@ -34,6 +34,7 @@ impl Command for Mv { ) .switch("interactive", "ask user to confirm action", Some('i')) .switch("force", "suppress error when no file", Some('f')) + .category(Category::FileSystem) } fn run( diff --git a/crates/nu-command/src/filesystem/rm.rs b/crates/nu-command/src/filesystem/rm.rs index 7c83b0bcc4..faea33e586 100644 --- a/crates/nu-command/src/filesystem/rm.rs +++ b/crates/nu-command/src/filesystem/rm.rs @@ -9,7 +9,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, SyntaxShape, Value, + Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, SyntaxShape, + Value, }; #[derive(Clone)] @@ -55,6 +56,7 @@ impl Command for Rm { SyntaxShape::GlobPattern, "the file path(s) to remove", ) + .category(Category::FileSystem) } fn run( diff --git a/crates/nu-command/src/filesystem/touch.rs b/crates/nu-command/src/filesystem/touch.rs index 0bc66dc06c..ece811c976 100644 --- a/crates/nu-command/src/filesystem/touch.rs +++ b/crates/nu-command/src/filesystem/touch.rs @@ -3,7 +3,7 @@ use std::fs::OpenOptions; use nu_engine::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}; #[derive(Clone)] pub struct Touch; @@ -21,6 +21,7 @@ impl Command for Touch { "the path of the file you want to create", ) .rest("rest", SyntaxShape::Filepath, "additional files to create") + .category(Category::FileSystem) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/collect.rs b/crates/nu-command/src/filters/collect.rs index 07074c0601..b7dd98125c 100644 --- a/crates/nu-command/src/filters/collect.rs +++ b/crates/nu-command/src/filters/collect.rs @@ -1,7 +1,7 @@ use nu_engine::eval_block; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Example, PipelineData, Signature, SyntaxShape, Value}; +use nu_protocol::{Category, Example, PipelineData, Signature, SyntaxShape, Value}; #[derive(Clone)] pub struct Collect; @@ -12,11 +12,13 @@ impl Command for Collect { } fn signature(&self) -> Signature { - Signature::build("collect").required( - "block", - SyntaxShape::Block(Some(vec![SyntaxShape::Any])), - "the block to run once the stream is collected", - ) + Signature::build("collect") + .required( + "block", + SyntaxShape::Block(Some(vec![SyntaxShape::Any])), + "the block to run once the stream is collected", + ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/each.rs b/crates/nu-command/src/filters/each.rs index 22a1ebaa75..533f81c785 100644 --- a/crates/nu-command/src/filters/each.rs +++ b/crates/nu-command/src/filters/each.rs @@ -2,8 +2,8 @@ use nu_engine::eval_block; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, Span, - SyntaxShape, Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, + Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -26,6 +26,7 @@ impl Command for Each { "the block to run", ) .switch("numbered", "iterate with an index", Some('n')) + .category(Category::Filters) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/filters/first.rs b/crates/nu-command/src/filters/first.rs index 1d2275984d..d3358ff9db 100644 --- a/crates/nu-command/src/filters/first.rs +++ b/crates/nu-command/src/filters/first.rs @@ -2,7 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Type, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, + Type, Value, }; #[derive(Clone)] @@ -14,11 +15,13 @@ impl Command for First { } fn signature(&self) -> Signature { - Signature::build("first").optional( - "rows", - SyntaxShape::Int, - "starting from the front, the number of rows to return", - ) + Signature::build("first") + .optional( + "rows", + SyntaxShape::Int, + "starting from the front, the number of rows to return", + ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/get.rs b/crates/nu-command/src/filters/get.rs index ffaf6a98ac..776667b500 100644 --- a/crates/nu-command/src/filters/get.rs +++ b/crates/nu-command/src/filters/get.rs @@ -1,7 +1,7 @@ use nu_engine::CallExt; use nu_protocol::ast::{Call, CellPath}; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, SyntaxShape}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, SyntaxShape}; #[derive(Clone)] pub struct Get; @@ -16,11 +16,13 @@ impl Command for Get { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("get").required( - "cell_path", - SyntaxShape::CellPath, - "the cell path to the data", - ) + Signature::build("get") + .required( + "cell_path", + SyntaxShape::CellPath, + "the cell path to the data", + ) + .category(Category::Filters) } fn run( diff --git a/crates/nu-command/src/filters/last.rs b/crates/nu-command/src/filters/last.rs index 2d9e929390..5dd93e16ed 100644 --- a/crates/nu-command/src/filters/last.rs +++ b/crates/nu-command/src/filters/last.rs @@ -3,8 +3,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Value, + Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, + SyntaxShape, Value, }; use std::convert::TryInto; @@ -17,11 +17,13 @@ impl Command for Last { } fn signature(&self) -> Signature { - Signature::build("last").optional( - "rows", - SyntaxShape::Int, - "starting from the back, the number of rows to return", - ) + Signature::build("last") + .optional( + "rows", + SyntaxShape::Int, + "starting from the back, the number of rows to return", + ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/length.rs b/crates/nu-command/src/filters/length.rs index 724018f851..f8bb8229c6 100644 --- a/crates/nu-command/src/filters/length.rs +++ b/crates/nu-command/src/filters/length.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, Value}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, Value}; #[derive(Clone)] pub struct Length; @@ -15,7 +15,7 @@ impl Command for Length { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("length") + Signature::build("length").category(Category::Filters) } fn run( diff --git a/crates/nu-command/src/filters/lines.rs b/crates/nu-command/src/filters/lines.rs index a4ad8143f6..5e282c3f71 100644 --- a/crates/nu-command/src/filters/lines.rs +++ b/crates/nu-command/src/filters/lines.rs @@ -1,6 +1,8 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value}; +use nu_protocol::{ + Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value, +}; #[derive(Clone)] pub struct Lines; @@ -17,7 +19,7 @@ impl Command for Lines { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("lines") + Signature::build("lines").category(Category::Filters) } fn run( diff --git a/crates/nu-command/src/filters/par_each.rs b/crates/nu-command/src/filters/par_each.rs index 95a34ecc1b..6e34c3e839 100644 --- a/crates/nu-command/src/filters/par_each.rs +++ b/crates/nu-command/src/filters/par_each.rs @@ -2,8 +2,8 @@ use nu_engine::eval_block; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, SyntaxShape, - Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, + SyntaxShape, Value, }; use rayon::prelude::*; @@ -27,6 +27,7 @@ impl Command for ParEach { "the block to run", ) .switch("numbered", "iterate with an index", Some('n')) + .category(Category::Filters) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/filters/range.rs b/crates/nu-command/src/filters/range.rs index 0280f51822..dce0a6c8a7 100644 --- a/crates/nu-command/src/filters/range.rs +++ b/crates/nu-command/src/filters/range.rs @@ -3,8 +3,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, - Value, + Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, + SyntaxShape, Value, }; #[derive(Clone)] @@ -16,11 +16,13 @@ impl Command for Range { } fn signature(&self) -> Signature { - Signature::build("range").optional( - "rows", - SyntaxShape::Range, - "range of rows to return: Eg) 4..7 (=> from 4 to 7)", - ) + Signature::build("range") + .optional( + "rows", + SyntaxShape::Range, + "range of rows to return: Eg) 4..7 (=> from 4 to 7)", + ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/reverse.rs b/crates/nu-command/src/filters/reverse.rs index c62d1e2bb1..3eccf3c1a9 100644 --- a/crates/nu-command/src/filters/reverse.rs +++ b/crates/nu-command/src/filters/reverse.rs @@ -1,7 +1,8 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, Value, + Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Span, + Value, }; #[derive(Clone)] @@ -13,7 +14,7 @@ impl Command for Reverse { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("reverse") + Signature::build("reverse").category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/select.rs b/crates/nu-command/src/filters/select.rs index aedf0378fa..4c8d4f9d51 100644 --- a/crates/nu-command/src/filters/select.rs +++ b/crates/nu-command/src/filters/select.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::{Call, CellPath}; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, Signature, - Span, SyntaxShape, Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, + Signature, Span, SyntaxShape, Value, }; #[derive(Clone)] @@ -15,11 +15,13 @@ impl Command for Select { } fn signature(&self) -> Signature { - Signature::build("select").rest( - "rest", - SyntaxShape::CellPath, - "the columns to select from the table", - ) + Signature::build("select") + .rest( + "rest", + SyntaxShape::CellPath, + "the columns to select from the table", + ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/shuffle.rs b/crates/nu-command/src/filters/shuffle.rs index f9e3dd75ef..4c3f07991c 100644 --- a/crates/nu-command/src/filters/shuffle.rs +++ b/crates/nu-command/src/filters/shuffle.rs @@ -1,6 +1,6 @@ use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoInterruptiblePipelineData, PipelineData, ShellError, Signature}; +use nu_protocol::{Category, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature}; use rand::prelude::SliceRandom; use rand::thread_rng; @@ -13,7 +13,7 @@ impl Command for Shuffle { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("shuffle") + Signature::build("shuffle").category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/update.rs b/crates/nu-command/src/filters/update.rs index 5e5b120ae2..a6bfdab0dc 100644 --- a/crates/nu-command/src/filters/update.rs +++ b/crates/nu-command/src/filters/update.rs @@ -2,7 +2,8 @@ use nu_engine::{eval_block, CallExt}; use nu_protocol::ast::{Call, CellPath}; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, + Value, }; #[derive(Clone)] @@ -25,6 +26,7 @@ impl Command for Update { SyntaxShape::Any, "the new value to give the cell(s)", ) + .category(Category::Filters) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/filters/where_.rs b/crates/nu-command/src/filters/where_.rs index 66f6b6fe89..e556b8fef2 100644 --- a/crates/nu-command/src/filters/where_.rs +++ b/crates/nu-command/src/filters/where_.rs @@ -1,7 +1,7 @@ use nu_engine::eval_expression; use nu_protocol::ast::{Call, Expr, Expression}; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{PipelineData, ShellError, Signature, SyntaxShape}; +use nu_protocol::{Category, PipelineData, ShellError, Signature, SyntaxShape}; #[derive(Clone)] pub struct Where; @@ -16,7 +16,9 @@ impl Command for Where { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("where").required("cond", SyntaxShape::RowCondition, "condition") + Signature::build("where") + .required("cond", SyntaxShape::RowCondition, "condition") + .category(Category::Filters) } fn run( diff --git a/crates/nu-command/src/filters/wrap.rs b/crates/nu-command/src/filters/wrap.rs index 48a7518586..0c92fbed29 100644 --- a/crates/nu-command/src/filters/wrap.rs +++ b/crates/nu-command/src/filters/wrap.rs @@ -2,7 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, SyntaxShape, Value, + Category, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, + SyntaxShape, Value, }; #[derive(Clone)] @@ -18,7 +19,9 @@ impl Command for Wrap { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("wrap").required("name", SyntaxShape::String, "the name of the column") + Signature::build("wrap") + .required("name", SyntaxShape::String, "the name of the column") + .category(Category::Filters) } fn run( diff --git a/crates/nu-command/src/filters/zip.rs b/crates/nu-command/src/filters/zip.rs index 49b082e76f..a0f273ebfe 100644 --- a/crates/nu-command/src/filters/zip.rs +++ b/crates/nu-command/src/filters/zip.rs @@ -2,8 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, SyntaxShape, - Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, Signature, + SyntaxShape, Value, }; #[derive(Clone)] @@ -19,7 +19,9 @@ impl Command for Zip { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("zip").required("other", SyntaxShape::Any, "the other input") + Signature::build("zip") + .required("other", SyntaxShape::Any, "the other input") + .category(Category::Filters) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/formats/from/command.rs b/crates/nu-command/src/formats/from/command.rs index f8de9bd635..719face4cf 100644 --- a/crates/nu-command/src/formats/from/command.rs +++ b/crates/nu-command/src/formats/from/command.rs @@ -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( diff --git a/crates/nu-command/src/formats/from/csv.rs b/crates/nu-command/src/formats/from/csv.rs index 02b350091c..3510a05ad2 100644 --- a/crates/nu-command/src/formats/from/csv.rs +++ b/crates/nu-command/src/formats/from/csv.rs @@ -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 { diff --git a/crates/nu-command/src/formats/from/eml.rs b/crates/nu-command/src/formats/from/eml.rs index 9ded63ea67..629db00880 100644 --- a/crates/nu-command/src/formats/from/eml.rs +++ b/crates/nu-command/src/formats/from/eml.rs @@ -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 { diff --git a/crates/nu-command/src/formats/from/json.rs b/crates/nu-command/src/formats/from/json.rs index 75c6bcfd3d..4f8c771445 100644 --- a/crates/nu-command/src/formats/from/json.rs +++ b/crates/nu-command/src/formats/from/json.rs @@ -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 { diff --git a/crates/nu-command/src/formats/from/tsv.rs b/crates/nu-command/src/formats/from/tsv.rs index 4f9a2e7085..075fab72a2 100644 --- a/crates/nu-command/src/formats/from/tsv.rs +++ b/crates/nu-command/src/formats/from/tsv.rs @@ -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 { diff --git a/crates/nu-command/src/formats/from/url.rs b/crates/nu-command/src/formats/from/url.rs index bc113be7bb..5d3f4731c5 100644 --- a/crates/nu-command/src/formats/from/url.rs +++ b/crates/nu-command/src/formats/from/url.rs @@ -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 { diff --git a/crates/nu-command/src/formats/from/yaml.rs b/crates/nu-command/src/formats/from/yaml.rs index 2114a84bdf..d463431db5 100644 --- a/crates/nu-command/src/formats/from/yaml.rs +++ b/crates/nu-command/src/formats/from/yaml.rs @@ -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 { diff --git a/crates/nu-command/src/formats/to/command.rs b/crates/nu-command/src/formats/to/command.rs index 226b7f30e2..068d875a55 100644 --- a/crates/nu-command/src/formats/to/command.rs +++ b/crates/nu-command/src/formats/to/command.rs @@ -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 To; @@ -15,7 +15,7 @@ impl Command for To { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("to") + Signature::build("to").category(Category::Formats) } fn run( diff --git a/crates/nu-command/src/formats/to/json.rs b/crates/nu-command/src/formats/to/json.rs index ac08404e08..6988af9028 100644 --- a/crates/nu-command/src/formats/to/json.rs +++ b/crates/nu-command/src/formats/to/json.rs @@ -1,8 +1,8 @@ use nu_protocol::ast::{Call, PathMember}; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, Signature, - Value, + Category, Example, IntoInterruptiblePipelineData, IntoPipelineData, PipelineData, ShellError, + Signature, Value, }; #[derive(Clone)] @@ -14,7 +14,7 @@ impl Command for ToJson { } fn signature(&self) -> Signature { - Signature::build("to json") + Signature::build("to json").category(Category::Formats) // .named( // "pretty", // SyntaxShape::Int, diff --git a/crates/nu-command/src/math/abs.rs b/crates/nu-command/src/math/abs.rs index 888317cd26..89341b89ae 100644 --- a/crates/nu-command/src/math/abs.rs +++ b/crates/nu-command/src/math/abs.rs @@ -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 { diff --git a/crates/nu-command/src/math/avg.rs b/crates/nu-command/src/math/avg.rs index f7de5be527..a5f6841a77 100644 --- a/crates/nu-command/src/math/avg.rs +++ b/crates/nu-command/src/math/avg.rs @@ -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 { diff --git a/crates/nu-command/src/math/ceil.rs b/crates/nu-command/src/math/ceil.rs index a23720ffbe..b9e032ee54 100644 --- a/crates/nu-command/src/math/ceil.rs +++ b/crates/nu-command/src/math/ceil.rs @@ -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 { diff --git a/crates/nu-command/src/math/command.rs b/crates/nu-command/src/math/command.rs index 6efc11f87c..266a0cc166 100644 --- a/crates/nu-command/src/math/command.rs +++ b/crates/nu-command/src/math/command.rs @@ -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 { diff --git a/crates/nu-command/src/math/eval.rs b/crates/nu-command/src/math/eval.rs index b8c79c116e..87265b021d 100644 --- a/crates/nu-command/src/math/eval.rs +++ b/crates/nu-command/src/math/eval.rs @@ -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( diff --git a/crates/nu-command/src/math/floor.rs b/crates/nu-command/src/math/floor.rs index ea1e4cbb43..cd8811d111 100644 --- a/crates/nu-command/src/math/floor.rs +++ b/crates/nu-command/src/math/floor.rs @@ -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 { diff --git a/crates/nu-command/src/math/max.rs b/crates/nu-command/src/math/max.rs index efe2422b06..2635192c57 100644 --- a/crates/nu-command/src/math/max.rs +++ b/crates/nu-command/src/math/max.rs @@ -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 { diff --git a/crates/nu-command/src/math/median.rs b/crates/nu-command/src/math/median.rs index 1204485fca..080c4fc044 100644 --- a/crates/nu-command/src/math/median.rs +++ b/crates/nu-command/src/math/median.rs @@ -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 { diff --git a/crates/nu-command/src/math/min.rs b/crates/nu-command/src/math/min.rs index a59db60c20..c897f4394b 100644 --- a/crates/nu-command/src/math/min.rs +++ b/crates/nu-command/src/math/min.rs @@ -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 { diff --git a/crates/nu-command/src/math/mode.rs b/crates/nu-command/src/math/mode.rs index baa8f2e739..619a02aeca 100644 --- a/crates/nu-command/src/math/mode.rs +++ b/crates/nu-command/src/math/mode.rs @@ -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 { diff --git a/crates/nu-command/src/math/product.rs b/crates/nu-command/src/math/product.rs index bfa2e85cbb..563d991371 100644 --- a/crates/nu-command/src/math/product.rs +++ b/crates/nu-command/src/math/product.rs @@ -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 { diff --git a/crates/nu-command/src/math/round.rs b/crates/nu-command/src/math/round.rs index b83c1f8ee1..1b6b9db5f7 100644 --- a/crates/nu-command/src/math/round.rs +++ b/crates/nu-command/src/math/round.rs @@ -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 { diff --git a/crates/nu-command/src/math/sqrt.rs b/crates/nu-command/src/math/sqrt.rs index 70ce9492f1..7cb9ca4d12 100644 --- a/crates/nu-command/src/math/sqrt.rs +++ b/crates/nu-command/src/math/sqrt.rs @@ -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 { diff --git a/crates/nu-command/src/math/stddev.rs b/crates/nu-command/src/math/stddev.rs index 2d7b2393ed..f7b231f277 100644 --- a/crates/nu-command/src/math/stddev.rs +++ b/crates/nu-command/src/math/stddev.rs @@ -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 { diff --git a/crates/nu-command/src/math/sum.rs b/crates/nu-command/src/math/sum.rs index 743241aa4a..814856dec2 100644 --- a/crates/nu-command/src/math/sum.rs +++ b/crates/nu-command/src/math/sum.rs @@ -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 { diff --git a/crates/nu-command/src/math/variance.rs b/crates/nu-command/src/math/variance.rs index a829682014..6252a49f87 100644 --- a/crates/nu-command/src/math/variance.rs +++ b/crates/nu-command/src/math/variance.rs @@ -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 { diff --git a/crates/nu-command/src/strings/build_string.rs b/crates/nu-command/src/strings/build_string.rs index 5c6692a3c6..9c6abada64 100644 --- a/crates/nu-command/src/strings/build_string.rs +++ b/crates/nu-command/src/strings/build_string.rs @@ -2,7 +2,8 @@ use nu_engine::eval_expression; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, + Value, }; #[derive(Clone)] @@ -18,7 +19,9 @@ impl Command for BuildString { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("build-string").rest("rest", SyntaxShape::String, "list of string") + Signature::build("build-string") + .rest("rest", SyntaxShape::String, "list of string") + .category(Category::Strings) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/strings/format/command.rs b/crates/nu-command/src/strings/format/command.rs index 2170dd722d..aac42acba9 100644 --- a/crates/nu-command/src/strings/format/command.rs +++ b/crates/nu-command/src/strings/format/command.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::{Call, PathMember}; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, ValueStream, + Category, Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, ValueStream, }; #[derive(Clone)] @@ -14,11 +14,13 @@ impl Command for Format { } fn signature(&self) -> Signature { - Signature::build("format").required( - "pattern", - SyntaxShape::String, - "the pattern to output. e.g.) \"{foo}: {bar}\"", - ) + Signature::build("format") + .required( + "pattern", + SyntaxShape::String, + "the pattern to output. e.g.) \"{foo}: {bar}\"", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/parse.rs b/crates/nu-command/src/strings/parse.rs index d1cdff0db0..bebf0fdc42 100644 --- a/crates/nu-command/src/strings/parse.rs +++ b/crates/nu-command/src/strings/parse.rs @@ -2,8 +2,8 @@ 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, Type, Value, - ValueStream, + Category, Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, + Value, ValueStream, }; use regex::Regex; @@ -27,6 +27,7 @@ impl Command for Parse { "the pattern to match. Eg) \"{foo}: {bar}\"", ) .switch("regex", "use full regex syntax for patterns", Some('r')) + .category(Category::Strings) } fn examples(&self) -> Vec { diff --git a/crates/nu-command/src/strings/size.rs b/crates/nu-command/src/strings/size.rs index c8307845c4..dd72d766b9 100644 --- a/crates/nu-command/src/strings/size.rs +++ b/crates/nu-command/src/strings/size.rs @@ -4,7 +4,7 @@ use unicode_segmentation::UnicodeSegmentation; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, Type, Value}; +use nu_protocol::{Category, Example, PipelineData, ShellError, Signature, Span, Type, Value}; #[derive(Clone)] pub struct Size; @@ -15,7 +15,7 @@ impl Command for Size { } fn signature(&self) -> Signature { - Signature::build("size") + Signature::build("size").category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/split/chars.rs b/crates/nu-command/src/strings/split/chars.rs index bfd48a2d80..1a03e1f131 100644 --- a/crates/nu-command/src/strings/split/chars.rs +++ b/crates/nu-command/src/strings/split/chars.rs @@ -1,7 +1,7 @@ use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Example, PipelineData, ShellError, Signature, Span, Type, Value, + Category, Example, PipelineData, ShellError, Signature, Span, Type, Value, }; #[derive(Clone)] @@ -13,7 +13,7 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("split chars") + Signature::build("split chars").category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/split/column.rs b/crates/nu-command/src/strings/split/column.rs index dbdfa28e11..4144b397b1 100644 --- a/crates/nu-command/src/strings/split/column.rs +++ b/crates/nu-command/src/strings/split/column.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, + Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, }; #[derive(Clone)] @@ -26,6 +26,7 @@ impl Command for SubCommand { SyntaxShape::String, "column names to give the new columns", ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/split/command.rs b/crates/nu-command/src/strings/split/command.rs index e6b30b3cce..60ab4f31a4 100644 --- a/crates/nu-command/src/strings/split/command.rs +++ b/crates/nu-command/src/strings/split/command.rs @@ -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 SplitCommand { } fn signature(&self) -> Signature { - Signature::build("split") + Signature::build("split").category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/split/row.rs b/crates/nu-command/src/strings/split/row.rs index b5ada3f149..8374bb3a09 100644 --- a/crates/nu-command/src/strings/split/row.rs +++ b/crates/nu-command/src/strings/split/row.rs @@ -2,7 +2,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, + Category, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Type, Value, }; #[derive(Clone)] @@ -14,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("split row").required( - "separator", - SyntaxShape::String, - "the character that denotes what separates rows", - ) + Signature::build("split row") + .required( + "separator", + SyntaxShape::String, + "the character that denotes what separates rows", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/capitalize.rs b/crates/nu-command/src/strings/str_/capitalize.rs index 91b3e6d590..e674a4306b 100644 --- a/crates/nu-command/src/strings/str_/capitalize.rs +++ b/crates/nu-command/src/strings/str_/capitalize.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; #[derive(Clone)] @@ -13,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str capitalize").rest( - "rest", - SyntaxShape::CellPath, - "optionally capitalize text by column paths", - ) + Signature::build("str capitalize") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally capitalize text by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/camel_case.rs b/crates/nu-command/src/strings/str_/case/camel_case.rs index 9c201937eb..db545453dc 100644 --- a/crates/nu-command/src/strings/str_/case/camel_case.rs +++ b/crates/nu-command/src/strings/str_/case/camel_case.rs @@ -1,7 +1,9 @@ use inflector::cases::camelcase::to_camel_case; 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, +}; use crate::operate; @@ -14,11 +16,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str camel-case").rest( - "rest", - SyntaxShape::CellPath, - "optionally convert text to camelCase by column paths", - ) + Signature::build("str camel-case") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally convert text to camelCase by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/command.rs b/crates/nu-command/src/strings/str_/case/command.rs index 40c038c7a3..ac43e6a9b0 100644 --- a/crates/nu-command/src/strings/str_/case/command.rs +++ b/crates/nu-command/src/strings/str_/case/command.rs @@ -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 Str { } fn signature(&self) -> Signature { - Signature::build("str") + Signature::build("str").category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/kebab_case.rs b/crates/nu-command/src/strings/str_/case/kebab_case.rs index 9cc6f9c154..a1afc324c6 100644 --- a/crates/nu-command/src/strings/str_/case/kebab_case.rs +++ b/crates/nu-command/src/strings/str_/case/kebab_case.rs @@ -1,7 +1,9 @@ use inflector::cases::kebabcase::to_kebab_case; 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, +}; use crate::operate; @@ -14,11 +16,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str kebab-case").rest( - "rest", - SyntaxShape::CellPath, - "optionally convert text to kebab-case by column paths", - ) + Signature::build("str kebab-case") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally convert text to kebab-case by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/pascal_case.rs b/crates/nu-command/src/strings/str_/case/pascal_case.rs index 5e6deaf40a..44dd100062 100644 --- a/crates/nu-command/src/strings/str_/case/pascal_case.rs +++ b/crates/nu-command/src/strings/str_/case/pascal_case.rs @@ -1,7 +1,9 @@ use inflector::cases::pascalcase::to_pascal_case; 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, +}; use crate::operate; @@ -14,11 +16,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str pascal-case").rest( - "rest", - SyntaxShape::CellPath, - "optionally convert text to PascalCase by column paths", - ) + Signature::build("str pascal-case") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally convert text to PascalCase by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs index ef178e66b2..e924c1ed6f 100644 --- a/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/screaming_snake_case.rs @@ -1,7 +1,9 @@ use inflector::cases::screamingsnakecase::to_screaming_snake_case; 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, +}; use crate::operate; #[derive(Clone)] @@ -13,11 +15,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str screaming-snake-case").rest( - "rest", - SyntaxShape::CellPath, - "optionally convert text to SCREAMING_SNAKE_CASE by column paths", - ) + Signature::build("str screaming-snake-case") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally convert text to SCREAMING_SNAKE_CASE by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/case/snake_case.rs b/crates/nu-command/src/strings/str_/case/snake_case.rs index f5bc419ddb..4a98186776 100644 --- a/crates/nu-command/src/strings/str_/case/snake_case.rs +++ b/crates/nu-command/src/strings/str_/case/snake_case.rs @@ -1,7 +1,9 @@ use inflector::cases::snakecase::to_snake_case; 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, +}; use crate::operate; #[derive(Clone)] @@ -13,11 +15,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str snake-case").rest( - "rest", - SyntaxShape::CellPath, - "optionally convert text to snake_case by column paths", - ) + Signature::build("str snake-case") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally convert text to snake_case by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { "converts a string to snake_case" diff --git a/crates/nu-command/src/strings/str_/collect.rs b/crates/nu-command/src/strings/str_/collect.rs index e4b2fead5b..af5a3d6f30 100644 --- a/crates/nu-command/src/strings/str_/collect.rs +++ b/crates/nu-command/src/strings/str_/collect.rs @@ -2,7 +2,8 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; use nu_protocol::{ - Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, SyntaxShape, + Value, }; #[derive(Clone)] @@ -14,11 +15,13 @@ impl Command for StrCollect { } fn signature(&self) -> Signature { - Signature::build("str collect").optional( - "separator", - SyntaxShape::String, - "optional separator to use when creating string", - ) + Signature::build("str collect") + .optional( + "separator", + SyntaxShape::String, + "optional separator to use when creating string", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/contains.rs b/crates/nu-command/src/strings/str_/contains.rs index 228f066b1f..7d50537a41 100644 --- a/crates/nu-command/src/strings/str_/contains.rs +++ b/crates/nu-command/src/strings/str_/contains.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{ Example, PipelineData, ShellError, Signature, Span, Spanned, SyntaxShape, Value, }; @@ -23,6 +24,7 @@ impl Command for SubCommand { "optionally check if string contains pattern by column paths", ) .switch("insensitive", "search is case insensitive", Some('i')) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/downcase.rs b/crates/nu-command/src/strings/str_/downcase.rs index 88ea405d0f..df8127497b 100644 --- a/crates/nu-command/src/strings/str_/downcase.rs +++ b/crates/nu-command/src/strings/str_/downcase.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; #[derive(Clone)] @@ -13,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str downcase").rest( - "rest", - SyntaxShape::CellPath, - "optionally downcase text by column paths", - ) + Signature::build("str downcase") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally downcase text by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/ends_with.rs b/crates/nu-command/src/strings/str_/ends_with.rs index 571a4a77be..059ccbd52f 100644 --- a/crates/nu-command/src/strings/str_/ends_with.rs +++ b/crates/nu-command/src/strings/str_/ends_with.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::Spanned; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; @@ -21,6 +22,7 @@ impl Command for SubCommand { SyntaxShape::CellPath, "optionally matches suffix of text by column paths", ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/find_replace.rs b/crates/nu-command/src/strings/str_/find_replace.rs index 637b3784ac..d486cb66bf 100644 --- a/crates/nu-command/src/strings/str_/find_replace.rs +++ b/crates/nu-command/src/strings/str_/find_replace.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::Spanned; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use regex::Regex; @@ -32,6 +33,7 @@ impl Command for SubCommand { "optionally find and replace text by column paths", ) .switch("all", "replace all occurrences of find string", Some('a')) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/index_of.rs b/crates/nu-command/src/strings/str_/index_of.rs index 40ae8e0389..af58b3775b 100644 --- a/crates/nu-command/src/strings/str_/index_of.rs +++ b/crates/nu-command/src/strings/str_/index_of.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::Spanned; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use std::sync::Arc; @@ -43,6 +44,7 @@ impl Command for SubCommand { Some('r'), ) .switch("end", "search from the end of the string", Some('e')) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/length.rs b/crates/nu-command/src/strings/str_/length.rs index df082e9a7e..4945c88c2b 100644 --- a/crates/nu-command/src/strings/str_/length.rs +++ b/crates/nu-command/src/strings/str_/length.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; #[derive(Clone)] @@ -13,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str length").rest( - "rest", - SyntaxShape::CellPath, - "optionally find length of text by column paths", - ) + Signature::build("str length") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally find length of text by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/lpad.rs b/crates/nu-command/src/strings/str_/lpad.rs index dedbcafa77..3ca04d2a80 100644 --- a/crates/nu-command/src/strings/str_/lpad.rs +++ b/crates/nu-command/src/strings/str_/lpad.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use std::sync::Arc; @@ -33,11 +34,13 @@ impl Command for SubCommand { SyntaxShape::CellPath, "optionally check if string contains pattern by column paths", ) + .category(Category::Strings) } fn usage(&self) -> &str { "pad a string with a character a certain length" } + fn run( &self, engine_state: &EngineState, diff --git a/crates/nu-command/src/strings/str_/reverse.rs b/crates/nu-command/src/strings/str_/reverse.rs index b2ab3340c2..8607671513 100644 --- a/crates/nu-command/src/strings/str_/reverse.rs +++ b/crates/nu-command/src/strings/str_/reverse.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; #[derive(Clone)] @@ -13,11 +14,13 @@ impl Command for SubCommand { } fn signature(&self) -> Signature { - Signature::build("str reverse").rest( - "rest", - SyntaxShape::CellPath, - "optionally reverse text by column paths", - ) + Signature::build("str reverse") + .rest( + "rest", + SyntaxShape::CellPath, + "optionally reverse text by column paths", + ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/rpad.rs b/crates/nu-command/src/strings/str_/rpad.rs index ebbe17313b..181489cee0 100644 --- a/crates/nu-command/src/strings/str_/rpad.rs +++ b/crates/nu-command/src/strings/str_/rpad.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use std::sync::Arc; @@ -33,6 +34,7 @@ impl Command for SubCommand { SyntaxShape::CellPath, "optionally check if string contains pattern by column paths", ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/strings/str_/starts_with.rs b/crates/nu-command/src/strings/str_/starts_with.rs index 4d3392b93b..9f26ba3f49 100644 --- a/crates/nu-command/src/strings/str_/starts_with.rs +++ b/crates/nu-command/src/strings/str_/starts_with.rs @@ -2,6 +2,7 @@ use nu_engine::CallExt; use nu_protocol::ast::Call; use nu_protocol::ast::CellPath; use nu_protocol::engine::{Command, EngineState, Stack}; +use nu_protocol::Category; use nu_protocol::Spanned; use nu_protocol::{Example, PipelineData, ShellError, Signature, Span, SyntaxShape, Value}; use std::sync::Arc; @@ -28,6 +29,7 @@ impl Command for SubCommand { SyntaxShape::CellPath, "optionally matches prefix of text by column paths", ) + .category(Category::Strings) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/system/benchmark.rs b/crates/nu-command/src/system/benchmark.rs index db9040ebdf..0b2f0b13e1 100644 --- a/crates/nu-command/src/system/benchmark.rs +++ b/crates/nu-command/src/system/benchmark.rs @@ -3,7 +3,7 @@ use std::time::Instant; use nu_engine::eval_block; use nu_protocol::ast::Call; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{IntoPipelineData, PipelineData, Signature, SyntaxShape, Value}; +use nu_protocol::{Category, IntoPipelineData, PipelineData, Signature, SyntaxShape, Value}; #[derive(Clone)] pub struct Benchmark; @@ -18,11 +18,13 @@ impl Command for Benchmark { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("benchmark").required( - "block", - SyntaxShape::Block(Some(vec![])), - "the block to run", - ) + Signature::build("benchmark") + .required( + "block", + SyntaxShape::Block(Some(vec![])), + "the block to run", + ) + .category(Category::System) } fn run( diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index a1f9e904f4..ed5d4a6e5d 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -1,7 +1,7 @@ use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value, + Category, Example, IntoInterruptiblePipelineData, PipelineData, ShellError, Signature, Value, }; use sysinfo::{ProcessExt, System, SystemExt}; @@ -22,6 +22,7 @@ impl Command for Ps { Some('l'), ) .filter() + .category(Category::System) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/system/run_external.rs b/crates/nu-command/src/system/run_external.rs index d0dedaee68..3689588822 100644 --- a/crates/nu-command/src/system/run_external.rs +++ b/crates/nu-command/src/system/run_external.rs @@ -8,7 +8,7 @@ use std::sync::mpsc; use nu_protocol::engine::{EngineState, Stack}; use nu_protocol::{ast::Call, engine::Command, ShellError, Signature, SyntaxShape, Value}; -use nu_protocol::{Config, IntoInterruptiblePipelineData, PipelineData, Span, Spanned}; +use nu_protocol::{Category, Config, IntoInterruptiblePipelineData, PipelineData, Span, Spanned}; use nu_engine::CallExt; @@ -26,10 +26,15 @@ impl Command for External { "Runs external command" } + fn is_private(&self) -> bool { + true + } + fn signature(&self) -> nu_protocol::Signature { Signature::build("run_external") .switch("last_expression", "last_expression", None) .rest("rest", SyntaxShape::Any, "external command to run") + .category(Category::System) } fn run( diff --git a/crates/nu-command/src/system/sys.rs b/crates/nu-command/src/system/sys.rs index 442a4136ca..c6c44237e7 100644 --- a/crates/nu-command/src/system/sys.rs +++ b/crates/nu-command/src/system/sys.rs @@ -1,7 +1,7 @@ use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, - Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value, + Category, Example, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value, }; use sysinfo::{ComponentExt, DiskExt, NetworkExt, ProcessorExt, System, SystemExt, UserExt}; @@ -17,6 +17,7 @@ impl Command for Sys { Signature::build("sys") .desc("View information about the current system.") .filter() + .category(Category::System) } fn usage(&self) -> &str { diff --git a/crates/nu-command/src/viewers/griddle.rs b/crates/nu-command/src/viewers/griddle.rs index e62315696d..9085bae487 100644 --- a/crates/nu-command/src/viewers/griddle.rs +++ b/crates/nu-command/src/viewers/griddle.rs @@ -3,7 +3,7 @@ use nu_engine::CallExt; use nu_protocol::{ ast::{Call, PathMember}, engine::{Command, EngineState, Stack}, - Config, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Value, + Category, Config, IntoPipelineData, PipelineData, Signature, Span, SyntaxShape, Value, }; use nu_term_grid::grid::{Alignment, Cell, Direction, Filling, Grid, GridOptions}; use terminal_size::{Height, Width}; @@ -35,6 +35,7 @@ impl Command for Griddle { "character to separate grid with", Some('s'), ) + .category(Category::Viewers) } fn extra_usage(&self) -> &str { diff --git a/crates/nu-command/src/viewers/table.rs b/crates/nu-command/src/viewers/table.rs index 9a4a7c5938..0efe075451 100644 --- a/crates/nu-command/src/viewers/table.rs +++ b/crates/nu-command/src/viewers/table.rs @@ -1,6 +1,8 @@ use nu_protocol::ast::{Call, PathMember}; use nu_protocol::engine::{Command, EngineState, Stack}; -use nu_protocol::{Config, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value}; +use nu_protocol::{ + Category, Config, IntoPipelineData, PipelineData, ShellError, Signature, Span, Value, +}; use nu_table::{StyledString, Theme}; use std::collections::HashMap; use std::sync::atomic::{AtomicBool, Ordering}; @@ -21,7 +23,7 @@ impl Command for Table { } fn signature(&self) -> nu_protocol::Signature { - Signature::build("table") + Signature::build("table").category(Category::Viewers) } fn run( diff --git a/crates/nu-engine/src/eval.rs b/crates/nu-engine/src/eval.rs index e53d19f617..a08327cc7d 100644 --- a/crates/nu-engine/src/eval.rs +++ b/crates/nu-engine/src/eval.rs @@ -536,10 +536,72 @@ pub fn eval_variable( } for command in &frame.decls { - commands.push(Value::String { + let mut cols = vec![]; + let mut vals = vec![]; + + cols.push("command".into()); + vals.push(Value::String { val: String::from_utf8_lossy(command.0).to_string(), span, }); + + let decl = engine_state.get_decl(*command.1); + let signature = decl.signature(); + cols.push("category".to_string()); + vals.push(Value::String { + val: signature.category.to_string(), + span, + }); + + cols.push("usage".to_string()); + vals.push(Value::String { + val: decl.usage().into(), + span, + }); + + cols.push("is_binary".to_string()); + vals.push(Value::Bool { + val: decl.is_binary(), + span, + }); + + cols.push("is_private".to_string()); + vals.push(Value::Bool { + val: decl.is_private(), + span, + }); + + cols.push("is_builtin".to_string()); + vals.push(Value::Bool { + val: decl.is_builtin(), + span, + }); + + cols.push("is_sub".to_string()); + vals.push(Value::Bool { + val: decl.is_sub(), + span, + }); + + cols.push("is_plugin".to_string()); + vals.push(Value::Bool { + val: decl.is_plugin(), + span, + }); + + cols.push("creates_scope".to_string()); + vals.push(Value::Bool { + val: signature.creates_scope, + span, + }); + + cols.push("extra_usage".to_string()); + vals.push(Value::String { + val: decl.extra_usage().into(), + span, + }); + + commands.push(Value::Record { cols, vals, span }) } for alias in &frame.aliases { diff --git a/crates/nu-plugin/schema/plugin.capnp b/crates/nu-plugin/schema/plugin.capnp index 2bc2bfd930..27b036d859 100644 --- a/crates/nu-plugin/schema/plugin.capnp +++ b/crates/nu-plugin/schema/plugin.capnp @@ -54,6 +54,23 @@ struct Signature { rest @5 :Argument; # Optional value. Check for existence when deserializing named @6 :List(Flag); isFilter @7 :Bool; + category @8 :Category; +} + +enum Category { + default @0; + conversions @1; + core @2; + date @3; + env @4; + experimental @5; + filesystem @6; + filters @7; + formats @8; + math @9; + strings @10; + system @11; + viewers @12; } struct Flag { diff --git a/crates/nu-plugin/src/plugin_capnp.rs b/crates/nu-plugin/src/plugin_capnp.rs index 19f22aa71d..2335881511 100644 --- a/crates/nu-plugin/src/plugin_capnp.rs +++ b/crates/nu-plugin/src/plugin_capnp.rs @@ -1652,6 +1652,12 @@ pub mod signature { pub fn get_is_filter(self) -> bool { self.reader.get_bool_field(0) } + #[inline] + pub fn get_category( + self, + ) -> ::core::result::Result { + ::capnp::traits::FromU16::from_u16(self.reader.get_data_field::(1)) + } } pub struct Builder<'a> { @@ -1912,6 +1918,16 @@ pub mod signature { pub fn set_is_filter(&mut self, value: bool) { self.builder.set_bool_field(0, value); } + #[inline] + pub fn get_category( + self, + ) -> ::core::result::Result { + ::capnp::traits::FromU16::from_u16(self.builder.get_data_field::(1)) + } + #[inline] + pub fn set_category(&mut self, value: crate::plugin_capnp::Category) { + self.builder.set_data_field::(1, value as u16) + } } pub struct Pipeline { @@ -1939,6 +1955,57 @@ pub mod signature { } } +#[repr(u16)] +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum Category { + Default = 0, + Conversions = 1, + Core = 2, + Date = 3, + Env = 4, + Experimental = 5, + Filesystem = 6, + Filters = 7, + Formats = 8, + Math = 9, + Strings = 10, + System = 11, + Viewers = 12, +} +impl ::capnp::traits::FromU16 for Category { + #[inline] + fn from_u16(value: u16) -> ::core::result::Result { + match value { + 0 => ::core::result::Result::Ok(Category::Default), + 1 => ::core::result::Result::Ok(Category::Conversions), + 2 => ::core::result::Result::Ok(Category::Core), + 3 => ::core::result::Result::Ok(Category::Date), + 4 => ::core::result::Result::Ok(Category::Env), + 5 => ::core::result::Result::Ok(Category::Experimental), + 6 => ::core::result::Result::Ok(Category::Filesystem), + 7 => ::core::result::Result::Ok(Category::Filters), + 8 => ::core::result::Result::Ok(Category::Formats), + 9 => ::core::result::Result::Ok(Category::Math), + 10 => ::core::result::Result::Ok(Category::Strings), + 11 => ::core::result::Result::Ok(Category::System), + 12 => ::core::result::Result::Ok(Category::Viewers), + n => ::core::result::Result::Err(::capnp::NotInSchema(n)), + } + } +} +impl ::capnp::traits::ToU16 for Category { + #[inline] + fn to_u16(self) -> u16 { + self as u16 + } +} +impl ::capnp::traits::HasTypeId for Category { + #[inline] + fn type_id() -> u64 { + 0x8920_14c1_76ba_5343u64 + } +} + pub mod flag { #[derive(Copy, Clone)] pub struct Owned(()); diff --git a/crates/nu-plugin/src/serializers/signature.rs b/crates/nu-plugin/src/serializers/signature.rs index 4aaf9ea36b..e54c1ec39a 100644 --- a/crates/nu-plugin/src/serializers/signature.rs +++ b/crates/nu-plugin/src/serializers/signature.rs @@ -1,6 +1,6 @@ use crate::plugin::PluginError; -use crate::plugin_capnp::{argument, flag, signature, Shape}; -use nu_protocol::{Flag, PositionalArg, Signature, SyntaxShape}; +use crate::plugin_capnp::{argument, flag, signature, Category as PluginCategory, Shape}; +use nu_protocol::{Category, Flag, PositionalArg, Signature, SyntaxShape}; pub(crate) fn serialize_signature(signature: &Signature, mut builder: signature::Builder) { builder.set_name(signature.name.as_str()); @@ -8,6 +8,22 @@ pub(crate) fn serialize_signature(signature: &Signature, mut builder: signature: builder.set_extra_usage(signature.extra_usage.as_str()); builder.set_is_filter(signature.is_filter); + match signature.category { + Category::Default => builder.set_category(PluginCategory::Default), + Category::Conversions => builder.set_category(PluginCategory::Conversions), + Category::Core => builder.set_category(PluginCategory::Core), + Category::Date => builder.set_category(PluginCategory::Date), + Category::Env => builder.set_category(PluginCategory::Env), + Category::Experimental => builder.set_category(PluginCategory::Experimental), + Category::FileSystem => builder.set_category(PluginCategory::Filesystem), + Category::Filters => builder.set_category(PluginCategory::Filters), + Category::Formats => builder.set_category(PluginCategory::Formats), + Category::Math => builder.set_category(PluginCategory::Math), + Category::Strings => builder.set_category(PluginCategory::Strings), + Category::System => builder.set_category(PluginCategory::System), + Category::Viewers => builder.set_category(PluginCategory::Viewers), + } + // Serializing list of required arguments let mut required_list = builder .reborrow() @@ -90,6 +106,25 @@ pub(crate) fn deserialize_signature(reader: signature::Reader) -> Result Category::Default, + PluginCategory::Conversions => Category::Conversions, + PluginCategory::Core => Category::Core, + PluginCategory::Date => Category::Date, + PluginCategory::Env => Category::Env, + PluginCategory::Experimental => Category::Experimental, + PluginCategory::Filesystem => Category::FileSystem, + PluginCategory::Filters => Category::Filters, + PluginCategory::Formats => Category::Formats, + PluginCategory::Math => Category::Math, + PluginCategory::Strings => Category::Strings, + PluginCategory::System => Category::System, + PluginCategory::Viewers => Category::Viewers, + }; + // Deserializing required arguments let required_list = reader .get_required_positional() @@ -141,6 +176,7 @@ pub(crate) fn deserialize_signature(reader: signature::Reader) -> Result Result { mod tests { use super::*; use capnp::serialize; - use nu_protocol::{Signature, SyntaxShape}; + use nu_protocol::{Category, Signature, SyntaxShape}; pub fn write_buffer( signature: &Signature, @@ -262,7 +298,8 @@ mod tests { Some('s'), ) .switch("switch", "some switch", None) - .rest("remaining", SyntaxShape::Int, "remaining"); + .rest("remaining", SyntaxShape::Int, "remaining") + .category(Category::Conversions); let mut buffer: Vec = Vec::new(); write_buffer(&signature, &mut buffer).expect("unable to serialize message"); @@ -273,6 +310,7 @@ mod tests { assert_eq!(signature.usage, returned_signature.usage); assert_eq!(signature.extra_usage, returned_signature.extra_usage); assert_eq!(signature.is_filter, returned_signature.is_filter); + assert_eq!(signature.category, returned_signature.category); signature .required_positional diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index caeda66362..43d3491f52 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -27,6 +27,45 @@ pub struct PositionalArg { pub var_id: Option, } +#[derive(Debug, Clone, PartialEq)] +pub enum Category { + Default, + Conversions, + Core, + Date, + Env, + Experimental, + FileSystem, + Filters, + Formats, + Math, + Strings, + System, + Viewers, +} + +impl std::fmt::Display for Category { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let msg = match self { + Category::Default => "default", + Category::Conversions => "conversions", + Category::Core => "core", + Category::Date => "date", + Category::Env => "env", + Category::Experimental => "experimental", + Category::FileSystem => "filesystem", + Category::Filters => "filters", + Category::Formats => "formats", + Category::Math => "math", + Category::Strings => "strings", + Category::System => "system", + Category::Viewers => "viewers", + }; + + write!(f, "{}", msg) + } +} + #[derive(Clone, Debug)] pub struct Signature { pub name: String, @@ -38,6 +77,8 @@ pub struct Signature { pub named: Vec, pub is_filter: bool, pub creates_scope: bool, + // Signature category used to classify commands stored in the list of declarations + pub category: Category, } impl PartialEq for Signature { @@ -75,6 +116,7 @@ impl Signature { named: vec![flag], is_filter: false, creates_scope: false, + category: Category::Default, } } pub fn build(name: impl Into) -> Signature { @@ -202,6 +244,13 @@ impl Signature { self } + /// Changes the signature category + pub fn category(mut self, category: Category) -> Signature { + self.category = category; + + self + } + /// Sets that signature will create a scope as it parses pub fn creates_scope(mut self) -> Signature { self.creates_scope = true;