use clap::Parser;
use crate::cli::{Cli, Command};
#[test]
fn cli_parses_hook_divert_check() {
let cli = Cli::try_parse_from(["trusty-mpm", "hook", "--divert-check"]).unwrap();
assert!(matches!(
cli.command.unwrap(),
Command::Hook {
pm_guard: false,
divert_check: true,
prompt_feedback: false
}
));
}
#[test]
fn cli_parses_divert_bulk_read() {
let cli = Cli::try_parse_from([
"trusty-mpm",
"divert",
"bulk-read",
"a.rs",
"b.rs",
"--prompt",
"what does this do?",
])
.unwrap();
match cli.command.unwrap() {
Command::Divert {
action:
crate::cli::DivertAction::BulkRead {
files,
prompt,
timeout_secs,
},
} => {
assert_eq!(files.len(), 2);
assert_eq!(prompt.as_deref(), Some("what does this do?"));
assert_eq!(
timeout_secs,
crate::commands::divert_worker::DEFAULT_TIMEOUT_SECS
);
}
other => panic!("expected Divert, got {other:?}"),
}
assert!(
Cli::try_parse_from(["trusty-mpm", "divert", "bulk-read"]).is_err(),
"bulk-read must require at least one file"
);
}