use clap::CommandFactory;
use std::{fs, path::PathBuf};
use grex_cli::cli::args::Cli;
const TAGLINE_PHRASE: &str = "nested meta-repo manager";
fn workspace_root() -> PathBuf {
let mut p = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
p.pop(); p.pop(); p
}
#[test]
fn clap_about_contains_nested_meta_repo_phrase() {
let cmd = Cli::command();
let about = cmd
.get_about()
.map(|s| s.to_string())
.expect("clap `about` must be set on the root Cli command");
assert!(
about.contains(TAGLINE_PHRASE),
"clap `about` must contain `{TAGLINE_PHRASE}`; got: {about:?}"
);
}
#[test]
fn man_page_grex_1_contains_nested_meta_repo_phrase() {
let path = workspace_root().join("man").join("grex.1");
let raw = fs::read_to_string(&path).unwrap_or_else(|e| panic!("read {}: {e}", path.display()));
let unescaped = raw.replace("\\-", "-");
assert!(
unescaped.contains("nested meta-repo"),
"man/grex.1 must mention `nested meta-repo` (after unescaping `\\-`); first 200 chars: {:?}",
&raw.chars().take(200).collect::<String>()
);
}
#[test]
fn readme_first_30_lines_contain_tagline_and_phrase() {
let path = workspace_root().join("README.md");
let body = fs::read_to_string(&path).unwrap_or_else(|e| panic!("read {}: {e}", path.display()));
let head: String = body.lines().take(30).collect::<Vec<_>>().join("\n");
assert!(
head.contains(TAGLINE_PHRASE),
"README.md first 30 lines must contain `{TAGLINE_PHRASE}`; got:\n{head}"
);
assert!(
head.contains("Pack-based, agent-native, Rust-fast"),
"README.md first 30 lines must contain the locked positioning triplet; got:\n{head}"
);
}