pub const SNOOZE: &str = "Snooze";
pub const SNOOZE_SOMETHING: &str = "Snooze something in Coming up";
pub const ONE_HOUR_LATER: &str = "1 hour later";
pub const TOMORROW_SAME_TIME: &str = "Tomorrow, same time";
pub const SNOOZING: &str = "Snoozing…";
pub const ON_YOUR_SCREENS: &str = "On your screens";
pub const AGENTS_ALWAYS_ASK_YOU_FIRST: &str = "Agents always ask you first";
pub const ASKS_YOU_FIRST_ALWAYS: &str = "When an agent wants to change something on your \
screens, it asks you first. This can't be switched off.";
pub const AGENTS_ALWAYS_ASK: &str = "Agents always ask before they change things on your screens.";
pub const GRANTED: &str = "Ask to change things on your screens — always asks you first";
pub const IT_MOVED: &str = "It moved since you saw this";
pub const ALREADY_STARTED: &str = "it has already started";
pub const NOT_ONE_TIME: &str = "it doesn't wait for one time, so it can't be snoozed";
pub const NOT_SCHEDULED: &str = "it isn't scheduled yet";
pub const ENDED: &str = "it has ended";
pub const NOT_FROM_HERE: &str = "Snoozing isn't available here — use the home";
pub const NOT_FROM_A_REMOTE_TERMINAL: &str =
"Snooze isn't available from a remote terminal — use the home.";
pub const AGENTS_ASK_THROUGH_THEIR_TOOLS: &str =
"An agent asks for a screen action through its own tool, and a person answers";
pub const VOICE_NOTE: &str = "By voice you can snooze what's coming up, say yes once, or no, to \
everyday things.";
pub const CANCELLED_NOTHING_CHANGED: &str = "Cancelled · nothing changed";
pub fn move_to(title: &str, when: &str) -> String {
format!("Move {title} to {when}")
}
pub(crate) fn title_of_move(heading: &str) -> Option<&str> {
let (title, _when) = heading.strip_prefix("Move ")?.rsplit_once(" to ")?;
(!title.is_empty()).then_some(title)
}
pub fn moved_to(title: &str, when: &str) -> String {
format!("Moved {title} to {when}")
}
pub fn snoozed(title: &str, when: &str) -> String {
format!("snoozed {title} → {when}")
}
pub fn cant_snooze(why: &str) -> String {
format!("Can't snooze: {why}")
}
pub fn only_moves_to(times: &[String]) -> String {
match times {
[one] => format!("It can only move to {one}"),
[first, second] => format!("It can only move to {first} or {second}"),
_ => format!("It can only move to {}", times.join(", ")),
}
}
pub fn ends_at(when: &str) -> String {
format!("It ends at {when}, so it can't move past then")
}
pub fn already_waiting(agent: &str, count: usize) -> String {
format!("{agent} already has {count} changes waiting for you")
}
pub fn nothing_called(title: &str) -> String {
format!("nothing in Coming up is called “{title}”")
}
pub fn things_match(count: usize, said: &str) -> String {
let count = match count {
2 => "Two".to_string(),
3 => "Three".to_string(),
4 => "Four".to_string(),
other => other.to_string(),
};
format!("{count} things match “{said}”")
}
pub fn snoozing_in(seconds: u64) -> String {
format!("Snoozing in {seconds} s")
}
pub fn heard(said: &str) -> String {
format!("Heard “{said}”")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn the_title_of_a_move_reads_back() {
for (title, when) in
[("News digest", "19:00"), ("Drive to work", "Tue 07:30"), ("to do", "08:00")]
{
assert_eq!(title_of_move(&move_to(title, when)), Some(title));
}
assert_eq!(title_of_move("Snooze something in Coming up"), None);
assert_eq!(title_of_move("Move to 19:00"), None);
}
}