Skip to content

Commit 9f28cbd

Browse files
authored
Gate run CLI command to debug builds only (#283)
1 parent 86de262 commit 9f28cbd

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

src/main.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod logging;
1212
mod mcp;
1313
mod ndjson;
1414
pub mod runtimes;
15+
#[cfg(debug_assertions)]
1516
mod run;
1617
pub mod sanitize;
1718
mod safeoutputs;
@@ -131,6 +132,7 @@ enum Commands {
131132
definition_ids: Option<Vec<u64>>,
132133
},
133134
/// Run agent locally (local development mode)
135+
#[cfg(debug_assertions)]
134136
Run {
135137
/// Path to the agent markdown file
136138
path: String,
@@ -181,6 +183,7 @@ async fn main() -> Result<()> {
181183
Some(Commands::McpHttp { .. }) => "mcp-http",
182184
Some(Commands::Init { .. }) => "init",
183185
Some(Commands::Configure { .. }) => "configure",
186+
#[cfg(debug_assertions)]
184187
Some(Commands::Run { .. }) => "run",
185188
None => "ado-aw",
186189
};
@@ -388,6 +391,7 @@ async fn main() -> Result<()> {
388391
)
389392
.await?;
390393
}
394+
#[cfg(debug_assertions)]
391395
Commands::Run {
392396
path,
393397
pat,

tests/cli_tests.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::path::PathBuf;
2+
3+
#[cfg(debug_assertions)]
4+
#[test]
5+
fn test_run_subcommand_exposed_in_debug_builds() {
6+
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
7+
let output = std::process::Command::new(&binary_path)
8+
.arg("--help")
9+
.output()
10+
.expect("Failed to run ado-aw --help");
11+
12+
assert!(output.status.success(), "--help should succeed");
13+
let stdout = String::from_utf8_lossy(&output.stdout);
14+
assert!(
15+
stdout.contains("Run agent locally"),
16+
"Debug build help output should include the run subcommand, got:\n{stdout}"
17+
);
18+
}
19+
20+
#[cfg(not(debug_assertions))]
21+
#[test]
22+
fn test_run_subcommand_not_exposed_in_release_builds() {
23+
let binary_path = PathBuf::from(env!("CARGO_BIN_EXE_ado-aw"));
24+
let output = std::process::Command::new(&binary_path)
25+
.arg("--help")
26+
.output()
27+
.expect("Failed to run ado-aw --help");
28+
29+
assert!(output.status.success(), "--help should succeed");
30+
let stdout = String::from_utf8_lossy(&output.stdout);
31+
assert!(
32+
!stdout.contains("Run agent locally"),
33+
"Release build help output should not include the run subcommand, got:\n{stdout}"
34+
);
35+
}

0 commit comments

Comments
 (0)