Skip to content

Commit 2be2074

Browse files
authored
Improve cli help messages (#185)
1 parent a93b142 commit 2be2074

File tree

4 files changed

+17
-33
lines changed

4 files changed

+17
-33
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ jobs:
5050
- run: poetry run pytest tests
5151
- run: poetry run pyright pynecone tests
5252
- run: poetry run pydocstyle pynecone tests
53-
- run: poetry run darglint pynecone tests
53+
- run: find pynecone tests -name "*.py" -not -path pynecone/pc.py | xargs poetry run darglint
5454
- run: poetry run black --check pynecone tests

pynecone/app.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@ def __call__(self) -> FastAPI:
8585
def add_default_endpoints(self):
8686
"""Add the default endpoints."""
8787
# To test the server.
88-
self.api.get(str(constants.Endpoint.PING))(_ping)
88+
self.api.get(str(constants.Endpoint.PING))(ping)
8989

9090
# To make state changes.
91-
self.api.websocket(str(constants.Endpoint.EVENT))(_event(app=self))
91+
self.api.websocket(str(constants.Endpoint.EVENT))(event(app=self))
9292

9393
def add_cors(self):
9494
"""Add CORS middleware to the app."""
@@ -290,7 +290,7 @@ def set_state(self, token: str, state: State):
290290
self.state_manager.set_state(token, state)
291291

292292

293-
async def _ping() -> str:
293+
async def ping() -> str:
294294
"""Test API endpoint.
295295
296296
Returns:
@@ -299,7 +299,7 @@ async def _ping() -> str:
299299
return "pong"
300300

301301

302-
def _event(app: App):
302+
def event(app: App):
303303
"""Websocket endpoint for events.
304304
305305
Args:

pynecone/pc.py

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ def version():
1919

2020
@cli.command()
2121
def init():
22-
"""Initialize a new Pynecone app.
23-
24-
Raises:
25-
Exit: If the app directory is invalid.
26-
"""
22+
"""Initialize a new Pynecone app in the current directory."""
2723
app_name = utils.get_default_app_name()
2824

2925
# Make sure they don't name the app "pynecone".
@@ -49,22 +45,16 @@ def init():
4945

5046
@cli.command()
5147
def run(
52-
env: constants.Env = constants.Env.DEV,
53-
frontend: bool = True,
54-
backend: bool = True,
55-
loglevel: constants.LogLevel = constants.LogLevel.ERROR,
48+
env: constants.Env = typer.Option(
49+
constants.Env.DEV, help="The environment to run the app in."
50+
),
51+
frontend: bool = typer.Option(True, help="Whether to run the frontend."),
52+
backend: bool = typer.Option(True, help="Whether to run the backend."),
53+
loglevel: constants.LogLevel = typer.Option(
54+
constants.LogLevel.ERROR, help="The log level to use."
55+
),
5656
):
57-
"""Run the app.
58-
59-
Args:
60-
env: The environment to run the app in.
61-
frontend: Whether to run the frontend.
62-
backend: Whether to run the backend.
63-
loglevel: The log level to use.
64-
65-
Raises:
66-
Exit: If the app is not initialized.
67-
"""
57+
"""Run the app in the current directory."""
6858
# Check that the app is initialized.
6959
if frontend and not utils.is_initialized():
7060
utils.console.print(
@@ -99,12 +89,8 @@ def run(
9989

10090

10191
@cli.command()
102-
def deploy(dry_run: bool = False):
103-
"""Deploy the app to the hosting service.
104-
105-
Args:
106-
dry_run: Whether to run a dry run.
107-
"""
92+
def deploy(dry_run: bool = typer.Option(False, help="Whether to run a dry run.")):
93+
"""Deploy the app to the Pynecone hosting service."""
10894
# Get the app config.
10995
config = utils.get_config()
11096
config.api_url = utils.get_production_backend_url()

pyproject.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,3 @@ pc = "pynecone.pc:main"
5252
[build-system]
5353
requires = ["poetry-core>=1.0.0"]
5454
build-backend = "poetry.core.masonry.api"
55-
56-
[tool.pyright]

0 commit comments

Comments
 (0)