-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
77 lines (63 loc) · 1.56 KB
/
main.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import os
import click
from app.commands.adminapi import AdminAPICommand
from app.commands.dataapi import DataAPICommand
from app.commands.generate_spec import GenerateSpecCommand
from app.commands.runtask import RunTaskCommand
from app.lib import commands
@click.group()
def cli():
pass
@cli.command(short_help=AdminAPICommand.help())
@click.option(
"-c",
"--config",
type=str,
default=lambda: os.environ.get("CONFIG", ""),
help="Path to configuration file",
)
def adminapi(config: str):
commands.run(AdminAPICommand(config))
@cli.command(short_help=DataAPICommand.help())
@click.option(
"-c",
"--config",
type=str,
default=lambda: os.environ.get("CONFIG", ""),
help="Path to configuration file",
)
def dataapi(config: str):
commands.run(DataAPICommand(config))
@cli.command(short_help=RunTaskCommand.help())
@click.argument(
"task_name",
required=True,
type=str,
)
@click.option(
"-c",
"--config",
type=str,
default=lambda: os.environ.get("CONFIG", ""),
help="Path to configuration file",
)
@click.option(
"-i",
"--input-data",
type=str,
help="Path to input data file",
)
def runtask(task_name: str, config: str, input_data: str | None):
commands.run(RunTaskCommand(task_name, config, input_data))
@cli.command(short_help=GenerateSpecCommand.help())
@click.option(
"-o",
"--output",
type=str,
required=True,
help="Where to put resulting JSON",
)
def generate_spec(output: str):
commands.run(GenerateSpecCommand(output))
if __name__ == "__main__":
cli()