SatisfactoryPlusCalculator/factorygame/helper.py

14 lines
327 B
Python
Raw Normal View History

import click
def prompt(options: dict[int, str], **kwargs) -> int | None:
for idx, label in options.items():
if label:
click.echo(f"{idx}: {label}")
ret = click.prompt(**kwargs)
ret = int(ret)
if ret not in options:
click.echo("Invalid choice.")
return None
return ret