From 4c787af26daf53805b29e6817fb3a5afef90c710 Mon Sep 17 00:00:00 2001 From: Darren Schroeder <343840+fdncred@users.noreply.github.com> Date: Mon, 13 Feb 2023 10:39:07 -0600 Subject: [PATCH] relocate debug commands (#8071) # Description Now that we've landed the debug commands we were working on, let's relocate them to an easier place to find all of them. That's what this PR does. The only actual code change was changing the `timeit` command to a `Category::Debug` command. The rest is just moving things around and hooking them up. # User-Facing Changes # Tests + Formatting Don't forget to add tests that cover your changes. Make sure you've run and fixed any issues with these commands: - `cargo fmt --all -- --check` to check standard code formatting (`cargo fmt --all` applies these changes) - `cargo clippy --workspace -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect` to check that you're using the standard code style - `cargo test --workspace` to check that all tests pass # After Submitting If your PR had any user-facing changes, update [the documentation](https://github.com/nushell/nushell.github.io) after the PR is merged, if necessary. This will help us keep the docs up to date. --- crates/nu-command/Cargo.toml | 1 - crates/nu-command/src/core_commands/mod.rs | 4 ---- .../debug.rs => debug/debug_.rs} | 0 .../src/{system => debug}/explain.rs | 0 .../src/{system => debug}/inspect.rs | 0 .../src/{system => debug}/inspect_table.rs | 2 +- .../src/{core_commands => debug}/metadata.rs | 0 crates/nu-command/src/debug/mod.rs | 23 +++++++++++++++++++ .../src/{experimental => debug}/profile.rs | 0 .../src/{system => debug}/timeit.rs | 2 +- .../src/{experimental => debug}/view.rs | 0 .../src/{experimental => debug}/view_files.rs | 0 .../{experimental => debug}/view_source.rs | 0 .../src/{experimental => debug}/view_span.rs | 0 crates/nu-command/src/default_context.rs | 22 ++++++++++-------- crates/nu-command/src/experimental/mod.rs | 10 -------- crates/nu-command/src/lib.rs | 2 ++ crates/nu-command/src/system/mod.rs | 8 ------- 18 files changed, 40 insertions(+), 34 deletions(-) rename crates/nu-command/src/{core_commands/debug.rs => debug/debug_.rs} (100%) rename crates/nu-command/src/{system => debug}/explain.rs (100%) rename crates/nu-command/src/{system => debug}/inspect.rs (100%) rename crates/nu-command/src/{system => debug}/inspect_table.rs (99%) rename crates/nu-command/src/{core_commands => debug}/metadata.rs (100%) create mode 100644 crates/nu-command/src/debug/mod.rs rename crates/nu-command/src/{experimental => debug}/profile.rs (100%) rename crates/nu-command/src/{system => debug}/timeit.rs (99%) rename crates/nu-command/src/{experimental => debug}/view.rs (100%) rename crates/nu-command/src/{experimental => debug}/view_files.rs (100%) rename crates/nu-command/src/{experimental => debug}/view_source.rs (100%) rename crates/nu-command/src/{experimental => debug}/view_span.rs (100%) diff --git a/crates/nu-command/Cargo.toml b/crates/nu-command/Cargo.toml index 3b4e5830a6..f843252dae 100644 --- a/crates/nu-command/Cargo.toml +++ b/crates/nu-command/Cargo.toml @@ -75,7 +75,6 @@ regex = "1.7.1" reqwest = { version = "0.11", features = ["blocking", "json"] } roxmltree = "0.18.0" rust-embed = "6.3.0" -rust-ini = "0.18.0" same-file = "1.0.6" serde = { version = "1.0.123", features = ["derive"] } serde_urlencoded = "0.7.0" diff --git a/crates/nu-command/src/core_commands/mod.rs b/crates/nu-command/src/core_commands/mod.rs index 6ed0d3bdb0..520a873b9c 100644 --- a/crates/nu-command/src/core_commands/mod.rs +++ b/crates/nu-command/src/core_commands/mod.rs @@ -4,7 +4,6 @@ mod break_; mod commandline; mod const_; mod continue_; -mod debug; mod def; mod def_env; mod describe; @@ -30,7 +29,6 @@ mod if_; mod ignore; mod let_; mod loop_; -mod metadata; mod module; mod mut_; pub(crate) mod overlay; @@ -46,7 +44,6 @@ pub use break_::Break; pub use commandline::Commandline; pub use const_::Const; pub use continue_::Continue; -pub use debug::Debug; pub use def::Def; pub use def_env::DefEnv; pub use describe::Describe; @@ -72,7 +69,6 @@ pub use if_::If; pub use ignore::Ignore; pub use let_::Let; pub use loop_::Loop; -pub use metadata::Metadata; pub use module::Module; pub use mut_::Mut; pub use overlay::*; diff --git a/crates/nu-command/src/core_commands/debug.rs b/crates/nu-command/src/debug/debug_.rs similarity index 100% rename from crates/nu-command/src/core_commands/debug.rs rename to crates/nu-command/src/debug/debug_.rs diff --git a/crates/nu-command/src/system/explain.rs b/crates/nu-command/src/debug/explain.rs similarity index 100% rename from crates/nu-command/src/system/explain.rs rename to crates/nu-command/src/debug/explain.rs diff --git a/crates/nu-command/src/system/inspect.rs b/crates/nu-command/src/debug/inspect.rs similarity index 100% rename from crates/nu-command/src/system/inspect.rs rename to crates/nu-command/src/debug/inspect.rs diff --git a/crates/nu-command/src/system/inspect_table.rs b/crates/nu-command/src/debug/inspect_table.rs similarity index 99% rename from crates/nu-command/src/system/inspect_table.rs rename to crates/nu-command/src/debug/inspect_table.rs index 36b0ea6604..8a51e18233 100644 --- a/crates/nu-command/src/system/inspect_table.rs +++ b/crates/nu-command/src/debug/inspect_table.rs @@ -118,7 +118,7 @@ mod truncate_table { } mod util { - use crate::system::explain::debug_string_without_formatting; + use crate::debug::explain::debug_string_without_formatting; use nu_engine::get_columns; use nu_protocol::{ast::PathMember, Span, Value}; diff --git a/crates/nu-command/src/core_commands/metadata.rs b/crates/nu-command/src/debug/metadata.rs similarity index 100% rename from crates/nu-command/src/core_commands/metadata.rs rename to crates/nu-command/src/debug/metadata.rs diff --git a/crates/nu-command/src/debug/mod.rs b/crates/nu-command/src/debug/mod.rs new file mode 100644 index 0000000000..d97cfe2483 --- /dev/null +++ b/crates/nu-command/src/debug/mod.rs @@ -0,0 +1,23 @@ +mod debug_; +mod explain; +mod inspect; +mod inspect_table; +mod metadata; +mod profile; +mod timeit; +mod view; +mod view_files; +mod view_source; +mod view_span; + +pub use debug_::Debug; +pub use explain::Explain; +pub use inspect::Inspect; +pub use inspect_table::build_table; +pub use metadata::Metadata; +pub use profile::Profile; +pub use timeit::TimeIt; +pub use view::View; +pub use view_files::ViewFiles; +pub use view_source::ViewSource; +pub use view_span::ViewSpan; diff --git a/crates/nu-command/src/experimental/profile.rs b/crates/nu-command/src/debug/profile.rs similarity index 100% rename from crates/nu-command/src/experimental/profile.rs rename to crates/nu-command/src/debug/profile.rs diff --git a/crates/nu-command/src/system/timeit.rs b/crates/nu-command/src/debug/timeit.rs similarity index 99% rename from crates/nu-command/src/system/timeit.rs rename to crates/nu-command/src/debug/timeit.rs index 0a29f553c7..d9e003693a 100644 --- a/crates/nu-command/src/system/timeit.rs +++ b/crates/nu-command/src/debug/timeit.rs @@ -31,7 +31,7 @@ impl Command for TimeIt { (Type::Nothing, Type::Duration), ]) .allow_variants_without_examples(true) - .category(Category::System) + .category(Category::Debug) } fn search_terms(&self) -> Vec<&str> { diff --git a/crates/nu-command/src/experimental/view.rs b/crates/nu-command/src/debug/view.rs similarity index 100% rename from crates/nu-command/src/experimental/view.rs rename to crates/nu-command/src/debug/view.rs diff --git a/crates/nu-command/src/experimental/view_files.rs b/crates/nu-command/src/debug/view_files.rs similarity index 100% rename from crates/nu-command/src/experimental/view_files.rs rename to crates/nu-command/src/debug/view_files.rs diff --git a/crates/nu-command/src/experimental/view_source.rs b/crates/nu-command/src/debug/view_source.rs similarity index 100% rename from crates/nu-command/src/experimental/view_source.rs rename to crates/nu-command/src/debug/view_source.rs diff --git a/crates/nu-command/src/experimental/view_span.rs b/crates/nu-command/src/debug/view_span.rs similarity index 100% rename from crates/nu-command/src/experimental/view_span.rs rename to crates/nu-command/src/debug/view_span.rs diff --git a/crates/nu-command/src/default_context.rs b/crates/nu-command/src/default_context.rs index 5d042cc355..e0ccc4a520 100644 --- a/crates/nu-command/src/default_context.rs +++ b/crates/nu-command/src/default_context.rs @@ -34,7 +34,6 @@ pub fn create_default_context() -> EngineState { Commandline, Const, Continue, - Debug, Def, DefEnv, Describe, @@ -65,7 +64,6 @@ pub fn create_default_context() -> EngineState { OverlayHide, Let, Loop, - Metadata, Module, Mut, Return, @@ -173,12 +171,23 @@ pub fn create_default_context() -> EngineState { // System bind_command! { Complete, - Explain, External, - Inspect, NuCheck, Sys, + }; + + // Debug + bind_command! { + Debug, + Explain, + Inspect, + Metadata, + Profile, TimeIt, + View, + ViewFiles, + ViewSource, + ViewSpan, }; #[cfg(unix)] @@ -471,11 +480,6 @@ pub fn create_default_context() -> EngineState { // Experimental bind_command! { IsAdmin, - Profile, - View, - ViewFiles, - ViewSource, - ViewSpan, }; // Deprecated diff --git a/crates/nu-command/src/experimental/mod.rs b/crates/nu-command/src/experimental/mod.rs index 54b38f1437..75328181a8 100644 --- a/crates/nu-command/src/experimental/mod.rs +++ b/crates/nu-command/src/experimental/mod.rs @@ -1,13 +1,3 @@ mod is_admin; -mod profile; -mod view; -mod view_files; -mod view_source; -mod view_span; pub use is_admin::IsAdmin; -pub use profile::Profile; -pub use view::View; -pub use view_files::ViewFiles; -pub use view_source::ViewSource; -pub use view_span::ViewSpan; diff --git a/crates/nu-command/src/lib.rs b/crates/nu-command/src/lib.rs index ea3c8e8a99..3c72e0853c 100644 --- a/crates/nu-command/src/lib.rs +++ b/crates/nu-command/src/lib.rs @@ -4,6 +4,7 @@ mod charting; mod conversions; mod core_commands; mod date; +mod debug; mod default_context; mod deprecated; mod env; @@ -34,6 +35,7 @@ pub use charting::*; pub use conversions::*; pub use core_commands::*; pub use date::*; +pub use debug::*; pub use default_context::*; pub use deprecated::*; pub use env::*; diff --git a/crates/nu-command/src/system/mod.rs b/crates/nu-command/src/system/mod.rs index 41a5402ee6..12ece2d93b 100644 --- a/crates/nu-command/src/system/mod.rs +++ b/crates/nu-command/src/system/mod.rs @@ -1,9 +1,6 @@ mod complete; #[cfg(unix)] mod exec; -mod explain; -mod inspect; -mod inspect_table; mod nu_check; #[cfg(any( target_os = "android", @@ -16,15 +13,11 @@ mod ps; mod registry_query; mod run_external; mod sys; -mod timeit; mod which_; pub use complete::Complete; #[cfg(unix)] pub use exec::Exec; -pub use explain::Explain; -pub use inspect::Inspect; -pub use inspect_table::build_table; pub use nu_check::NuCheck; #[cfg(any( target_os = "android", @@ -37,5 +30,4 @@ pub use ps::Ps; pub use registry_query::RegistryQuery; pub use run_external::{External, ExternalCommand}; pub use sys::Sys; -pub use timeit::TimeIt; pub use which_::Which;