-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcli.py
More file actions
48 lines (37 loc) · 967 Bytes
/
cli.py
File metadata and controls
48 lines (37 loc) · 967 Bytes
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
import click
from sample.utils.constants import PORT, PORT_API
from . import __version__
@click.group(
invoke_without_command=True,
help="""
Sample command-line tools.
To configure MongoDB support, install with:
pip install sample[mongo]
""",
)
@click.option("--version", is_flag=True, help="Show the Sample version and exit.")
@click.pass_context
def cli(ctx, version):
if version:
click.echo(__version__)
ctx.exit()
@cli.command(help="Run the Sample Streamlit app.")
@click.option(
"--port",
default=int(PORT),
show_default=True,
help="Port to run the Streamlit app on.",
)
def dev(port: int):
from sample.__main__ import main
main(port)
@cli.command(help="Run the Sample FastAPI backend.")
@click.option(
"--port",
default=int(PORT_API),
show_default=True,
help="Port to run the FastAPI backend on.",
)
def api(port: int):
from sample.api.fast_api import start
start(port)