use click::command::Command;
use click::context::Context;
use click::group::{CommandLike, Group};
use click::option::ClickOption;
fn build_cli() -> Group {
let sub = Command::new("deploy")
.help("Deploy a topology to the server.")
.option(
ClickOption::new(&["--workspace-directory"])
.help("Workspace source directory")
.build(),
)
.callback(|_ctx: &Context| Ok(()))
.build();
Group::new("podium").command(sub).build()
}
#[test]
fn subcommand_help_returns_ok_not_silent_exit() {
let cli = build_cli();
let result = cli.main(vec!["deploy".to_string(), "--help".to_string()]);
assert!(
result.is_ok(),
"subcommand --help must resolve to the printed-help Ok path, got: {result:?}"
);
}
#[test]
fn subcommand_help_text_is_nonempty_and_has_usage() {
let cli = build_cli();
let ctx = click::context::ContextBuilder::new()
.info_name("podium deploy")
.build();
let sub = Command::new("deploy")
.help("Deploy a topology to the server.")
.option(
ClickOption::new(&["--workspace-directory"])
.help("Workspace source directory")
.build(),
)
.build();
let help = sub.get_help(&ctx);
assert!(!help.trim().is_empty(), "subcommand help must not be empty");
assert!(
help.contains("Usage:") && help.contains("--workspace-directory"),
"help must contain usage line and option names, got:\n{help}"
);
let _ = cli; }