Skip to content

Custom commands#3019

Merged
ahopkins merged 9 commits into
mainfrom
custom-commands
Dec 31, 2024
Merged

Custom commands#3019
ahopkins merged 9 commits into
mainfrom
custom-commands

Conversation

@ahopkins

Copy link
Copy Markdown
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
@ahopkins ahopkins deleted the custom-commands branch December 31, 2024 12:11
@ahopkins ahopkins mentioned this pull request Dec 31, 2024
1 task
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