use super::{argv, said};
use crate::cli::{Decided, run};
#[track_caller]
fn started(words: &[&str]) -> (Option<String>, Option<String>) {
match run(argv(words)) {
Decided::Start { dir, role, .. } => (dir, role),
other => panic!("{words:?} decided {other:?}"),
}
}
#[test]
fn the_rung_is_positional_and_the_role_is_written() {
assert_eq!(started(&["start", "home", "go"]), (None, None));
assert_eq!(
started(&["start", "home", "go", "/w"]),
(Some("/w".to_owned()), None)
);
assert_eq!(
started(&["start", "home", "go", "--role", "planner"]),
(None, Some("planner".to_owned()))
);
assert_eq!(
started(&["start", "home", "go", "/w", "--role", "planner"]),
(Some("/w".to_owned()), Some("planner".to_owned()))
);
}
#[test]
fn the_role_word_with_no_name_refuses_and_teaches_the_tail() {
let refusal = said(&["start", "home", "go", "--role"]);
assert!(refusal.text.contains("--role"), "{}", refusal.text);
assert!(
refusal.text.contains(&crate::verbs::doors::START.usage()),
"{}",
refusal.text
);
}
#[test]
fn a_role_this_seat_cannot_know_is_carried_rather_than_refused() {
assert_eq!(
started(&["start", "home", "go", "--role", "a-role-from-2027"]),
(None, Some("a-role-from-2027".to_owned()))
);
}