From 1e16f1e450b32256a0364584c6f3e6cc6657f280 Mon Sep 17 00:00:00 2001 From: Wesley Shields Date: Fri, 16 Aug 2024 15:35:31 -0400 Subject: [PATCH] Add "developer" feature and put "debug" command behind it. Add a "developer" feature that enables the debug command. Prior to this the command was always available but just hidden. This makes it a compile-time feature that can be useful if you're into doing developer type things like debugging the syntax trees. --- cli/Cargo.toml | 4 ++++ cli/src/commands/debug.rs | 2 +- cli/src/commands/mod.rs | 2 ++ cli/src/main.rs | 1 + 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index aaf1607e0..f70f2410d 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -22,6 +22,10 @@ path = "src/main.rs" # to work fine in Linux. profiling = ["pprof"] +# Enable the "debug" command. Calling it "developer" here because calling it +# "debug" is confusing as that implies a debug build. +developer = [] + # When this feature is enabled the CLI program prints debug logs if # the RUST_LOG environment variable is set to any of the debug levels: # diff --git a/cli/src/commands/debug.rs b/cli/src/commands/debug.rs index 22027c7ef..de395a10f 100644 --- a/cli/src/commands/debug.rs +++ b/cli/src/commands/debug.rs @@ -1,3 +1,4 @@ +#![cfg(feature = "developer")] use std::fs; use std::path::PathBuf; @@ -47,7 +48,6 @@ pub fn debug() -> Command { super::command("debug") .about("Debug utilities") .arg_required_else_help(true) - .hide(true) .subcommand(ast()) .subcommand(cst()) .subcommand(wasm()) diff --git a/cli/src/commands/mod.rs b/cli/src/commands/mod.rs index 8cbc360b2..1be59010a 100644 --- a/cli/src/commands/mod.rs +++ b/cli/src/commands/mod.rs @@ -10,6 +10,7 @@ mod scan; pub use check::*; pub use compile::*; pub use completion::*; +#[cfg(feature = "developer")] pub use debug::*; pub use dump::*; pub use fix::*; @@ -54,6 +55,7 @@ pub fn cli() -> Command { commands::scan(), commands::compile(), commands::check(), + #[cfg(feature = "developer")] commands::debug(), commands::dump(), commands::fmt(), diff --git a/cli/src/main.rs b/cli/src/main.rs index f36d96e79..d43f37edc 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -56,6 +56,7 @@ fn main() -> anyhow::Result<()> { })); let result = match args.subcommand() { + #[cfg(feature = "developer")] Some(("debug", args)) => commands::exec_debug(args), Some(("check", args)) => commands::exec_check(args), Some(("fix", args)) => commands::exec_fix(args),