-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcli.py
39 lines (33 loc) · 829 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import re
import sys
import typer
import seed.seed_runner
app = typer.Typer()
@app.command()
def list_seed():
"""
show all function inside seed.seed_runner.py\n
you can add/remove seed by edit seed.seed_runner.py
"""
for item in dir(seed.seed_runner):
if not re.search('^__.*__$', item):
typer.echo(f'- {item}')
@app.command()
def run_seed(func_name:str):
"""
Run seeder function inside seed.seed_runner.py\n
you can add/remove seed by edit seed.seed_runner.py
"""
try:
method_to_call = getattr(seed.seed_runner, func_name)
method_to_call()
except Exception as e:
typer.echo(str(e))
@app.command()
def show_python_version():
"""
show python version used
"""
typer.echo(sys.version)
if __name__ == "__main__":
app()