feat(nav): helpful error for unknown destinations
This commit is contained in:
parent
b07115022a
commit
4e43c5e060
1 changed files with 3 additions and 0 deletions
3
nav.py
3
nav.py
|
|
@ -56,6 +56,9 @@ def plan(destination):
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
destination = sys.argv[1]
|
destination = sys.argv[1]
|
||||||
|
if destination not in ROUTES:
|
||||||
|
known = ", ".join(sorted(ROUTES))
|
||||||
|
sys.exit(f"Unknown destination: {destination} (known: {known})")
|
||||||
route, total, days, fuel = plan(destination)
|
route, total, days, fuel = plan(destination)
|
||||||
print("Route: " + " -> ".join(NAMES[w] for w in route))
|
print("Route: " + " -> ".join(NAMES[w] for w in route))
|
||||||
print(f"Distance: {total:.1f} million km")
|
print(f"Distance: {total:.1f} million km")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue