[feat] add auxiliary CLI commands for shell completions and man page generation; refactor logging with verbosity levels and macros; update tests and TODOs

This commit is contained in:
2025-08-08 14:02:36 +02:00
parent 1cad6d593d
commit 933d01d7ec
6 changed files with 201 additions and 46 deletions

45
tests/integration_aux.rs Normal file
View File

@@ -0,0 +1,45 @@
use std::process::Command;
fn bin() -> &'static str { env!("CARGO_BIN_EXE_polyscribe") }
#[test]
fn aux_completions_bash_outputs_script() {
let out = Command::new(bin())
.arg("completions")
.arg("bash")
.output()
.expect("failed to run polyscribe completions bash");
assert!(out.status.success(), "completions bash exited with failure: {:?}", out.status);
let stdout = String::from_utf8(out.stdout).expect("stdout not utf-8");
assert!(!stdout.trim().is_empty(), "completions bash stdout is empty");
// Heuristic: bash completion scripts often contain 'complete -F' lines
assert!(stdout.contains("complete") || stdout.contains("_polyscribe"), "bash completion script did not contain expected markers");
}
#[test]
fn aux_completions_zsh_outputs_script() {
let out = Command::new(bin())
.arg("completions")
.arg("zsh")
.output()
.expect("failed to run polyscribe completions zsh");
assert!(out.status.success(), "completions zsh exited with failure: {:?}", out.status);
let stdout = String::from_utf8(out.stdout).expect("stdout not utf-8");
assert!(!stdout.trim().is_empty(), "completions zsh stdout is empty");
// Heuristic: zsh completion scripts often start with '#compdef'
assert!(stdout.contains("#compdef") || stdout.contains("#compdef polyscribe"), "zsh completion script did not contain expected markers");
}
#[test]
fn aux_man_outputs_roff() {
let out = Command::new(bin())
.arg("man")
.output()
.expect("failed to run polyscribe man");
assert!(out.status.success(), "man exited with failure: {:?}", out.status);
let stdout = String::from_utf8(out.stdout).expect("stdout not utf-8");
assert!(!stdout.trim().is_empty(), "man stdout is empty");
// clap_mangen typically emits roff with .TH and/or section headers
let looks_like_roff = stdout.contains(".TH ") || stdout.starts_with(".TH") || stdout.contains(".SH NAME") || stdout.contains(".SH SYNOPSIS");
assert!(looks_like_roff, "man output does not look like a roff manpage; got: {}", &stdout.lines().take(3).collect::<Vec<_>>().join(" | "));
}