-
Notifications
You must be signed in to change notification settings - Fork 21
/
cli.py
25 lines (18 loc) · 777 Bytes
/
cli.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import argparse
from helpers import get_random_athlete
def get_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description="Get a random athlete")
parser.add_argument("-s", "--search", help="Search by name")
group = parser.add_mutually_exclusive_group()
group.add_argument("-q", "--quiet", action="store_true", help="print quiet")
group.add_argument("-v", "--verbose", action="store_true", help="print verbose")
return parser
def main() -> None:
parser = get_parser()
args = parser.parse_args()
random_athlete = get_random_athlete(
search=args.search, quiet=args.quiet, verbose=args.verbose
)
print(random_athlete if random_athlete else "No athletes found")
if __name__ == "__main__":
main()