forked from extern/nushell
Collapse some help commands
columns into a single column (#7052)
This commit is contained in:
parent
24d72ca43c
commit
fe14e52e77
@ -136,21 +136,9 @@ fn help(
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_plugin".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_plugin().is_some(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_custom".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_custom_command(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_keyword".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_parser_keyword(),
|
||||
cols.push("command_type".into());
|
||||
vals.push(Value::String {
|
||||
val: format!("{:?}", decl.command_type()).to_lowercase(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
@ -247,21 +235,9 @@ fn help(
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_plugin".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_plugin().is_some(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_custom".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_custom_command(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
cols.push("is_keyword".into());
|
||||
vals.push(Value::Bool {
|
||||
val: decl.is_parser_keyword(),
|
||||
cols.push("command_type".into());
|
||||
vals.push(Value::String {
|
||||
val: format!("{:?}", decl.command_type()).to_lowercase(),
|
||||
span: head,
|
||||
});
|
||||
|
||||
|
@ -4,6 +4,15 @@ use crate::{ast::Call, BlockId, Example, PipelineData, ShellError, Signature};
|
||||
|
||||
use super::{EngineState, Stack};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum CommandType {
|
||||
Builtin,
|
||||
Custom,
|
||||
Keyword,
|
||||
Plugin,
|
||||
Other,
|
||||
}
|
||||
|
||||
pub trait Command: Send + Sync + CommandClone {
|
||||
fn name(&self) -> &str;
|
||||
|
||||
@ -71,6 +80,21 @@ pub trait Command: Send + Sync + CommandClone {
|
||||
fn search_terms(&self) -> Vec<&str> {
|
||||
vec![]
|
||||
}
|
||||
|
||||
fn command_type(&self) -> CommandType {
|
||||
match (
|
||||
self.is_builtin(),
|
||||
self.is_custom_command(),
|
||||
self.is_parser_keyword(),
|
||||
self.is_plugin().is_some(),
|
||||
) {
|
||||
(true, false, false, false) => CommandType::Builtin,
|
||||
(false, true, false, false) => CommandType::Custom,
|
||||
(_, false, true, false) => CommandType::Keyword,
|
||||
(false, false, false, true) => CommandType::Plugin,
|
||||
_ => CommandType::Other,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait CommandClone {
|
||||
|
Loading…
Reference in New Issue
Block a user