Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom commands #3019

Merged
merged 9 commits into from
Dec 31, 2024
Merged

Custom commands #3019

merged 9 commits into from
Dec 31, 2024

Conversation

ahopkins
Copy link
Member

This adds the ability to add commands to the sanic CLI.

@app.command
async def foo(one, two: str, three: str = "..."):
    logger.info(f"FOO {one=} {two=} {three=}")


@app.command
def bar():
    logger.info("BAR")


@app.command(name="qqq")
async def baz():
    logger.info("BAZ")

These are invoked using

sanic server:app exec <command> [--arg=value]

@ahopkins ahopkins requested a review from a team as a code owner December 31, 2024 11:54
@ahopkins ahopkins merged commit 4327b8b into main Dec 31, 2024
25 checks passed
@ahopkins ahopkins deleted the custom-commands branch December 31, 2024 12:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant