From bc48b4553c9e2f4d590a014ca6e1bf0931b44988 Mon Sep 17 00:00:00 2001 From: Michael Angerman <1809991+stormasm@users.noreply.github.com> Date: Thu, 16 Jun 2022 09:58:38 -0700 Subject: [PATCH] Move the history and tutor commands out of core_commands (#5813) * move history and tutor commands from core to misc * add in the Misc Category for the history and tutor commands --- crates/nu-command/src/core_commands/mod.rs | 4 ---- crates/nu-command/src/default_context.rs | 8 ++++++-- crates/nu-command/src/lib.rs | 2 ++ crates/nu-command/src/{core_commands => misc}/history.rs | 2 +- crates/nu-command/src/misc/mod.rs | 5 +++++ crates/nu-command/src/{core_commands => misc}/tutor.rs | 2 +- crates/nu-protocol/src/signature.rs | 2 ++ 7 files changed, 17 insertions(+), 8 deletions(-) rename crates/nu-command/src/{core_commands => misc}/history.rs (99%) create mode 100644 crates/nu-command/src/misc/mod.rs rename crates/nu-command/src/{core_commands => misc}/tutor.rs (99%) diff --git a/crates/nu-command/src/core_commands/mod.rs b/crates/nu-command/src/core_commands/mod.rs index 39d4f4e143..60a1ab6df3 100644 --- a/crates/nu-command/src/core_commands/mod.rs +++ b/crates/nu-command/src/core_commands/mod.rs @@ -16,7 +16,6 @@ mod extern_; mod for_; mod help; mod hide; -mod history; mod if_; mod ignore; mod let_; @@ -24,7 +23,6 @@ mod metadata; mod module; pub(crate) mod overlay; mod source; -mod tutor; mod use_; mod version; @@ -46,7 +44,6 @@ pub use extern_::Extern; pub use for_::For; pub use help::Help; pub use hide::Hide; -pub use history::History; pub use if_::If; pub use ignore::Ignore; pub use let_::Let; @@ -54,7 +51,6 @@ pub use metadata::Metadata; pub use module::Module; pub use overlay::*; pub use source::Source; -pub use tutor::Tutor; pub use use_::Use; pub use version::Version; #[cfg(feature = "plugin")] diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index b12caec253..aa403d213f 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -48,7 +48,6 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { For, Help, Hide, - History, If, Ignore, Overlay, @@ -60,7 +59,6 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { Metadata, Module, Source, - Tutor, Use, Version, }; @@ -134,6 +132,12 @@ pub fn create_default_context(cwd: impl AsRef) -> EngineState { Zip, }; + // Misc + bind_command! { + History, + Tutor, + }; + // Path bind_command! { Path, diff --git a/crates/nu-command/src/lib.rs b/crates/nu-command/src/lib.rs index f16778a71a..45ad3f493d 100644 --- a/crates/nu-command/src/lib.rs +++ b/crates/nu-command/src/lib.rs @@ -13,6 +13,7 @@ mod formats; mod generators; mod hash; mod math; +mod misc; mod network; mod path; mod platform; @@ -38,6 +39,7 @@ pub use formats::*; pub use generators::*; pub use hash::*; pub use math::*; +pub use misc::*; pub use network::*; pub use path::*; pub use platform::*; diff --git a/crates/nu-command/src/core_commands/history.rs b/crates/nu-command/src/misc/history.rs similarity index 99% rename from crates/nu-command/src/core_commands/history.rs rename to crates/nu-command/src/misc/history.rs index 1a65b55bb3..2110649179 100644 --- a/crates/nu-command/src/core_commands/history.rs +++ b/crates/nu-command/src/misc/history.rs @@ -24,7 +24,7 @@ impl Command for History { fn signature(&self) -> nu_protocol::Signature { Signature::build("history") .switch("clear", "Clears out the history entries", Some('c')) - .category(Category::Core) + .category(Category::Misc) } fn run( diff --git a/crates/nu-command/src/misc/mod.rs b/crates/nu-command/src/misc/mod.rs new file mode 100644 index 0000000000..fcb539f60e --- /dev/null +++ b/crates/nu-command/src/misc/mod.rs @@ -0,0 +1,5 @@ +mod history; +mod tutor; + +pub use history::History; +pub use tutor::Tutor; diff --git a/crates/nu-command/src/core_commands/tutor.rs b/crates/nu-command/src/misc/tutor.rs similarity index 99% rename from crates/nu-command/src/core_commands/tutor.rs rename to crates/nu-command/src/misc/tutor.rs index 76a3e59db6..d2d952494b 100644 --- a/crates/nu-command/src/core_commands/tutor.rs +++ b/crates/nu-command/src/misc/tutor.rs @@ -28,7 +28,7 @@ impl Command for Tutor { "Search tutorial for a phrase", Some('f'), ) - .category(Category::Core) + .category(Category::Misc) } fn usage(&self) -> &str { diff --git a/crates/nu-protocol/src/signature.rs b/crates/nu-protocol/src/signature.rs index 778ba7d37a..3aefd54a4a 100644 --- a/crates/nu-protocol/src/signature.rs +++ b/crates/nu-protocol/src/signature.rs @@ -49,6 +49,7 @@ pub enum Category { Filters, Formats, Math, + Misc, Network, Random, Platform, @@ -76,6 +77,7 @@ impl std::fmt::Display for Category { Category::Filters => "filters", Category::Formats => "formats", Category::Math => "math", + Category::Misc => "misc", Category::Network => "network", Category::Random => "random", Category::Platform => "platform",