morning.py
python · 110 lines
1"""A quiet morning ritual for the terminal.23Nothing is saved. Nothing accumulates. Every run is the first run.4"""56import random7import sys8import time910# Delay between each character in the typewriter effect, in seconds.11TYPING_DELAY: float = 0.031213# Pause after a full line is revealed, in seconds.14LINE_PAUSE: float = 0.81516# Breathing room before and after the prompt, in seconds.17PROMPT_PAUSE: float = 1.01819# Greetings, chosen at random each run.20GREETINGS: tuple[str, ...] = (21 "\u2600\ufe0e Good morning.",22 "\U0001f375 A quiet moment, before the day begins.",23 "\U0001f33f You are here.",24)2526# Closings, chosen at random each run.27CLOSINGS: tuple[str, ...] = (28 "Thank you. That is enough.",29 "The morning is yours. Begin.",30 "Nothing held. Nothing kept. Go gently.",31)323334def slow_print(text: str) -> None:35 """Print text one character at a time, like a gentle typewriter.3637 Each character is flushed immediately to create a smooth38 reveal effect. A brief pause follows the completed line.3940 Args:41 text: The message to display.42 """43 for character in text:44 sys.stdout.write(character)45 sys.stdout.flush()46 time.sleep(TYPING_DELAY)47 sys.stdout.write("\n")48 sys.stdout.flush()49 time.sleep(LINE_PAUSE)505152def print_greeting() -> None:53 """Display a soft, randomized greeting.5455 Prints blank lines for spacing, then reveals a greeting56 chosen at random from the available options.57 """58 print()59 greeting = random.choice(GREETINGS)60 slow_print(greeting)61 print()626364def prompt_user() -> str:65 """Invite the user to share one sentence.6667 Waits quietly for a single line of input. The sentence68 is received but never stored beyond this moment.6970 Returns:71 The sentence the user entered.72 """73 time.sleep(PROMPT_PAUSE)74 slow_print("What is on your mind this morning?")75 print()76 sentence = input(" \u2192 ")77 print()78 time.sleep(PROMPT_PAUSE)79 return sentence808182def print_closing() -> None:83 """Display a gentle closing message.8485 Chooses a closing at random and reveals it slowly,86 leaving space around it so the words can breathe.87 """88 closing = random.choice(CLOSINGS)89 slow_print(closing)90 print()919293def main() -> None:94 """Run the morning ritual.9596 The flow is simple and unchanging: greet, listen, close.97 Nothing from the session is saved or remembered.98 """99 try:100 print_greeting()101 prompt_user()102 print_closing()103 except (KeyboardInterrupt, EOFError):104 # If the user leaves early, exit quietly.105 print()106107108if __name__ == "__main__":109 main()110