flask-restx icon indicating copy to clipboard operation
flask-restx copied to clipboard

Is there a way to register commands with Namespaces?

Open spitfiredd opened this issue 3 years ago • 1 comments

Ask a question I would like to register a command with a Namespace similarly to how Flask does it

For example,

import click
from ..views import api


@api.cli.command("setup")
@click.argument("name")
def create(name):
    return f"Successfully created {name}"

and from my .view.py

from flask_restx import Namespace


api = Namespace("search", description="Search data with Elasticsearch.")

Running flask search create alice returns Error: No such command 'search'.; similarly running flask --help doesn't like the command in the Commands section.

Additional context N/A

spitfiredd avatar Aug 23 '22 17:08 spitfiredd

I can just create a Blueprint for /api/search/cli; I don't need to hook into the Namespace object.

spitfiredd avatar Aug 23 '22 18:08 spitfiredd