Add Band Name Generator project with CLI, tests, and documentation
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Band Name Generator: combine a hometown and a pet's name into a band name."""
|
||||
@@ -0,0 +1,3 @@
|
||||
from band_name_generator.cli import main
|
||||
|
||||
main()
|
||||
@@ -0,0 +1,19 @@
|
||||
"""Command-line interface for the Band Name Generator."""
|
||||
|
||||
from band_name_generator.generator import generate_band_name
|
||||
|
||||
|
||||
def main() -> None:
|
||||
print("Welcome to the Band Name Generator.")
|
||||
city = input("What's the name of the city you grew up in?\n")
|
||||
pet = input("What's the name of a pet?\n")
|
||||
try:
|
||||
band_name = generate_band_name(city, pet)
|
||||
except ValueError as error:
|
||||
print(error)
|
||||
raise SystemExit(1)
|
||||
print(f"Your band name could be: {band_name}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -0,0 +1,13 @@
|
||||
"""Core logic for building a band name."""
|
||||
|
||||
|
||||
def generate_band_name(city: str, pet: str) -> str:
|
||||
"""Combine a city and a pet's name into a band name.
|
||||
|
||||
Raises ValueError if either value is empty or only whitespace.
|
||||
"""
|
||||
city = city.strip()
|
||||
pet = pet.strip()
|
||||
if not city or not pet:
|
||||
raise ValueError("Both the city and the pet's name are required.")
|
||||
return f"{city} {pet}"
|
||||
Reference in New Issue
Block a user