-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathcli.py
executable file
·53 lines (41 loc) · 1.08 KB
/
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python3
import asyncio
import click
from main import generate
from main import list
@click.group()
def cli():
pass
@click.command()
@click.option(
"--count", default=5, help="How many emails to generate", type=int
)
def generatecommand(count: int):
"Generate emails"
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(generate(count))
except KeyboardInterrupt:
pass
@click.command()
@click.option(
"--active/--inactive", default=True, help="Filter Active / Inactive emails"
)
@click.option("--search", default=None, help="Search emails")
def listcommand(active, search):
"List emails"
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(list(active, search))
except KeyboardInterrupt:
pass
cli.add_command(listcommand, name="list")
cli.add_command(generatecommand, name="generate")
if __name__ == "__main__":
cli()
if __name__ == "__main__":
loop = asyncio.new_event_loop()
try:
loop.run_until_complete(generate(None))
except KeyboardInterrupt:
pass