Complete the end-to-end CLI parity audit

This commit is contained in:
Hermes Agent
2026-08-10 01:51:47 +00:00
parent 4bd39b1ef2
commit 0a905e5e14
14 changed files with 1476 additions and 95 deletions

View File

@@ -3,9 +3,10 @@
use std::{error::Error, num::NonZeroUsize, path::Path};
use ironstorage::command::{
CliAction, CommandRequest, EXIT_USAGE, GeneratedPresentation, GitConfigRequest,
GitRemoteRequest, GitRequest, HelpTopic, InputPlan, InsertInput, OtpInputSource, OtpRequest,
OtpUriPresentation, Presentation, help_text, otp_version_text, parse_from, version_text,
CliAction, CommandRequest, CompletionShell, EXIT_USAGE, GeneratedPresentation,
GitConfigRequest, GitRemoteRequest, GitRequest, HelpTopic, InputPlan, InsertInput,
OtpInputSource, OtpRequest, OtpUriPresentation, Presentation, completion_script, help_text,
otp_version_text, parse_from, version_text,
};
type TestResult = Result<(), Box<dyn Error>>;
@@ -19,6 +20,39 @@ fn request(arguments: &[&str]) -> Result<CommandRequest, Box<dyn Error>> {
}
}
#[test]
fn completion_scripts_are_generated_in_process_for_supported_shells() -> TestResult {
for (name, shell, marker) in [
("bash", CompletionShell::Bash, "complete"),
("elvish", CompletionShell::Elvish, "edit:completion"),
("fish", CompletionShell::Fish, "complete"),
(
"powershell",
CompletionShell::PowerShell,
"Register-ArgumentCompleter",
),
("zsh", CompletionShell::Zsh, "compdef"),
] {
assert_eq!(
request(&["completion", name])?,
CommandRequest::Completion { shell }
);
let script = String::from_utf8(completion_script(shell))?;
assert!(script.contains("ironstorage"));
assert!(
script.contains(marker),
"missing {marker} in {name} completion"
);
}
assert_eq!(
parse_from(["ironstorage", "completion", "unsupported"])
.unwrap_err()
.exit_code(),
EXIT_USAGE
);
Ok(())
}
#[test]
fn implicit_show_and_list_aliases_are_canonical_requests() -> TestResult {
assert!(matches!(