mirror of
https://github.com/nushell/nushell.git
synced 2025-04-24 21:28:20 +02:00
Fix command_type classification (#7074)
- Custom commands are true for builtin and custom - Add classification as external command - Specify wildcard in keyword: keyword is true for builtin and keyword
This commit is contained in:
parent
fe14e52e77
commit
bb0d08a721
@ -99,6 +99,8 @@ impl Command for Let {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
use nu_protocol::engine::CommandType;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -107,4 +109,9 @@ mod test {
|
|||||||
|
|
||||||
test_examples(Let {})
|
test_examples(Let {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_command_type() {
|
||||||
|
assert!(matches!(Let.command_type(), CommandType::Keyword));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -292,6 +292,9 @@ pub fn process(
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
|
|
||||||
|
use nu_protocol::engine::CommandType;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -300,4 +303,9 @@ mod test {
|
|||||||
|
|
||||||
test_examples(Sort {})
|
test_examples(Sort {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_command_type() {
|
||||||
|
assert!(matches!(Sort.command_type(), CommandType::Builtin));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ pub enum CommandType {
|
|||||||
Builtin,
|
Builtin,
|
||||||
Custom,
|
Custom,
|
||||||
Keyword,
|
Keyword,
|
||||||
|
External,
|
||||||
Plugin,
|
Plugin,
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
@ -86,12 +87,14 @@ pub trait Command: Send + Sync + CommandClone {
|
|||||||
self.is_builtin(),
|
self.is_builtin(),
|
||||||
self.is_custom_command(),
|
self.is_custom_command(),
|
||||||
self.is_parser_keyword(),
|
self.is_parser_keyword(),
|
||||||
|
self.is_known_external(),
|
||||||
self.is_plugin().is_some(),
|
self.is_plugin().is_some(),
|
||||||
) {
|
) {
|
||||||
(true, false, false, false) => CommandType::Builtin,
|
(true, false, false, false, false) => CommandType::Builtin,
|
||||||
(false, true, false, false) => CommandType::Custom,
|
(true, true, false, false, false) => CommandType::Custom,
|
||||||
(_, false, true, false) => CommandType::Keyword,
|
(true, false, true, false, false) => CommandType::Keyword,
|
||||||
(false, false, false, true) => CommandType::Plugin,
|
(false, true, false, true, false) => CommandType::External,
|
||||||
|
(false, false, false, false, true) => CommandType::Plugin,
|
||||||
_ => CommandType::Other,
|
_ => CommandType::Other,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user