Improve cli help messages (#185)
This commit is contained in:
parent
a93b1425c7
commit
2be20745f1
2
.github/workflows/build.yml
vendored
2
.github/workflows/build.yml
vendored
@ -50,5 +50,5 @@ jobs:
|
|||||||
- run: poetry run pytest tests
|
- run: poetry run pytest tests
|
||||||
- run: poetry run pyright pynecone tests
|
- run: poetry run pyright pynecone tests
|
||||||
- run: poetry run pydocstyle pynecone tests
|
- run: poetry run pydocstyle pynecone tests
|
||||||
- run: poetry run darglint pynecone tests
|
- run: find pynecone tests -name "*.py" -not -path pynecone/pc.py | xargs poetry run darglint
|
||||||
- run: poetry run black --check pynecone tests
|
- run: poetry run black --check pynecone tests
|
||||||
|
@ -85,10 +85,10 @@ class App(Base):
|
|||||||
def add_default_endpoints(self):
|
def add_default_endpoints(self):
|
||||||
"""Add the default endpoints."""
|
"""Add the default endpoints."""
|
||||||
# To test the server.
|
# To test the server.
|
||||||
self.api.get(str(constants.Endpoint.PING))(_ping)
|
self.api.get(str(constants.Endpoint.PING))(ping)
|
||||||
|
|
||||||
# To make state changes.
|
# To make state changes.
|
||||||
self.api.websocket(str(constants.Endpoint.EVENT))(_event(app=self))
|
self.api.websocket(str(constants.Endpoint.EVENT))(event(app=self))
|
||||||
|
|
||||||
def add_cors(self):
|
def add_cors(self):
|
||||||
"""Add CORS middleware to the app."""
|
"""Add CORS middleware to the app."""
|
||||||
@ -290,7 +290,7 @@ class App(Base):
|
|||||||
self.state_manager.set_state(token, state)
|
self.state_manager.set_state(token, state)
|
||||||
|
|
||||||
|
|
||||||
async def _ping() -> str:
|
async def ping() -> str:
|
||||||
"""Test API endpoint.
|
"""Test API endpoint.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@ -299,7 +299,7 @@ async def _ping() -> str:
|
|||||||
return "pong"
|
return "pong"
|
||||||
|
|
||||||
|
|
||||||
def _event(app: App):
|
def event(app: App):
|
||||||
"""Websocket endpoint for events.
|
"""Websocket endpoint for events.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
@ -19,11 +19,7 @@ def version():
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def init():
|
def init():
|
||||||
"""Initialize a new Pynecone app.
|
"""Initialize a new Pynecone app in the current directory."""
|
||||||
|
|
||||||
Raises:
|
|
||||||
Exit: If the app directory is invalid.
|
|
||||||
"""
|
|
||||||
app_name = utils.get_default_app_name()
|
app_name = utils.get_default_app_name()
|
||||||
|
|
||||||
# Make sure they don't name the app "pynecone".
|
# Make sure they don't name the app "pynecone".
|
||||||
@ -49,22 +45,16 @@ def init():
|
|||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def run(
|
def run(
|
||||||
env: constants.Env = constants.Env.DEV,
|
env: constants.Env = typer.Option(
|
||||||
frontend: bool = True,
|
constants.Env.DEV, help="The environment to run the app in."
|
||||||
backend: bool = True,
|
),
|
||||||
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
|
frontend: bool = typer.Option(True, help="Whether to run the frontend."),
|
||||||
|
backend: bool = typer.Option(True, help="Whether to run the backend."),
|
||||||
|
loglevel: constants.LogLevel = typer.Option(
|
||||||
|
constants.LogLevel.ERROR, help="The log level to use."
|
||||||
|
),
|
||||||
):
|
):
|
||||||
"""Run the app.
|
"""Run the app in the current directory."""
|
||||||
|
|
||||||
Args:
|
|
||||||
env: The environment to run the app in.
|
|
||||||
frontend: Whether to run the frontend.
|
|
||||||
backend: Whether to run the backend.
|
|
||||||
loglevel: The log level to use.
|
|
||||||
|
|
||||||
Raises:
|
|
||||||
Exit: If the app is not initialized.
|
|
||||||
"""
|
|
||||||
# Check that the app is initialized.
|
# Check that the app is initialized.
|
||||||
if frontend and not utils.is_initialized():
|
if frontend and not utils.is_initialized():
|
||||||
utils.console.print(
|
utils.console.print(
|
||||||
@ -99,12 +89,8 @@ def run(
|
|||||||
|
|
||||||
|
|
||||||
@cli.command()
|
@cli.command()
|
||||||
def deploy(dry_run: bool = False):
|
def deploy(dry_run: bool = typer.Option(False, help="Whether to run a dry run.")):
|
||||||
"""Deploy the app to the hosting service.
|
"""Deploy the app to the Pynecone hosting service."""
|
||||||
|
|
||||||
Args:
|
|
||||||
dry_run: Whether to run a dry run.
|
|
||||||
"""
|
|
||||||
# Get the app config.
|
# Get the app config.
|
||||||
config = utils.get_config()
|
config = utils.get_config()
|
||||||
config.api_url = utils.get_production_backend_url()
|
config.api_url = utils.get_production_backend_url()
|
||||||
|
@ -52,5 +52,3 @@ pc = "pynecone.pc:main"
|
|||||||
[build-system]
|
[build-system]
|
||||||
requires = ["poetry-core>=1.0.0"]
|
requires = ["poetry-core>=1.0.0"]
|
||||||
build-backend = "poetry.core.masonry.api"
|
build-backend = "poetry.core.masonry.api"
|
||||||
|
|
||||||
[tool.pyright]
|
|
||||||
|
Loading…
Reference in New Issue
Block a user