Skip to content

Commit

Permalink
Add "developer" feature and put "debug" command behind it.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
wxsBSD committed Aug 16, 2024
1 parent 7cc5459 commit 1e16f1e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
4 changes: 4 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
#
Expand Down
2 changes: 1 addition & 1 deletion cli/src/commands/debug.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#![cfg(feature = "developer")]
use std::fs;
use std::path::PathBuf;

Expand Down Expand Up @@ -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())
Expand Down
2 changes: 2 additions & 0 deletions cli/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -54,6 +55,7 @@ pub fn cli() -> Command {
commands::scan(),
commands::compile(),
commands::check(),
#[cfg(feature = "developer")]
commands::debug(),
commands::dump(),
commands::fmt(),
Expand Down
1 change: 1 addition & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down

0 comments on commit 1e16f1e

Please sign in to comment.