Skip to main content

Enhance Flask development workflow with powerful CLI commands for inspecting application.

Project description

Flask-CLI-Extend

Enhance Flask development workflow with powerful CLI commands for inspecting application.

Why this Plugin?

While Flask provides a robust framework for building web applications, the default CLI tools can sometimes be limited for developers who need to quickly inspect the structure and configuration of their application. This extension aims to fill that gap by providing clear, concise, and colorful outputs for commonly needed information, such as registered blueprints, URL routes, and application configurations. This helps to improve developer productivity and makes debugging and introspection easier.

Installation

pip install flask-cli-extend

Configuration

You can customize the behavior of this extension by setting the following variables in your Flask application's configuration file (e.g., config.py).

FLASK_CLI_EXTEND_TABLE_COLORS

This variable allows you to customize the colors of the output tables.

Type: list[str]

Default: ["yellow", "cyan", "green", "blue", "magenta"]

Available colors: click Supported color.

Example:

FLASK_CLI_EXTEND_TABLE_COLORS = ["red", "blue"]

FLASK_CLI_EXTEND_SENSITIVE_CONFIG_KEYS

This variable allows you to add to the list of sensitive keys that should be masked in the output of the flask configs command.

Type: list[str]

Default: ["SECRET", "KEY", "PASSWORD", "TOKEN"]

Example:

FLASK_CLI_EXTEND_SENSITIVE_CONFIG_KEYS = ["URI", "PWD"]

Usage

Once installed, the new commands will be available through the flask command.

flask blueprints

Displays information about registered Flask blueprints.

Options:

  • --sort, -s: Sorts the blueprints by name.

Output:

The command outputs a table with the following columns:

  • Name: The name of the blueprint.
  • Import Name: The import name of the blueprint.
  • Relative Path: The relative path to the blueprint's root.
  • URL Prefix: The URL prefix for the blueprint.
  • Subdomain: The subdomain for the blueprint (if any).

Example output:

Name      Import Name      Relative Path      URL Prefix
--------  ---------------  -----------------  ------------
main      app.main         src/app/main
api       app.api          src/app/api        /api

flask routes

Shows all registered routes with endpoints and methods.

Options:

  • --sort, -s {endpoint,methods,domain,rule,match}: Method to sort routes by. 'match' is the order that Flask will match routes when dispatching a request.
  • --blueprint, -b TEXT: Show the routes for the blueprint.
  • --all-methods, -A: Show HEAD and OPTIONS methods.

Output:

The command outputs a table with the following columns:

  • Endpoint: The endpoint name.
  • Methods: The HTTP methods allowed for the route.
  • Rule: The URL rule.
  • Host / Subdomain: The host or subdomain for the route (if any).

Example output:

Endpoint    Methods    Rule          Host
----------  ---------  ------------  ------
main.index  GET        /
main.about  GET        /about
api.users   GET, POST  /api/users

flask configs

Displays application configuration parameters.

Options:

  • --default, -d: Show default config parameters.
  • --show-sensitive, -S: Show sensitive values.
  • --diff, -D: Show differences between current app and default config settings.
  • --namespace, -n TEXT: Show config parameters that match the specified namespace/prefix.
  • --no-namespace, -N TEXT: Show config parameters excluding those that match the specified namespace/prefix.

Output:

The command outputs a table with the following columns:

  • Key: The configuration key.
  • Value: The configuration value.

Sensitive values are masked by default.

Example output:

Key               Value
----------------  ----------------------
DEBUG             False
SECRET_KEY        ab0*******
SQLALCHEMY_DB_URI postgresql://...

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the BSD License. See the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_cli_extend-0.1.0.tar.gz (42.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_cli_extend-0.1.0-py3-none-any.whl (8.6 kB view details)

Uploaded Python 3

File details

Details for the file flask_cli_extend-0.1.0.tar.gz.

File metadata

  • Download URL: flask_cli_extend-0.1.0.tar.gz
  • Upload date:
  • Size: 42.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for flask_cli_extend-0.1.0.tar.gz
Algorithm Hash digest
SHA256 72ffe7600be026ce7e8f8628e00703be235f1f41b67a82dd91ebdc9d27ec37d2
MD5 240332b2f51cf3332c452102fdd0006c
BLAKE2b-256 065ba1159c1349584759809e6c0a6367ba80999c16a561ec8058a9f7796654cd

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_cli_extend-0.1.0.tar.gz:

Publisher: publish.yaml on curskey/flask-cli-extend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flask_cli_extend-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_cli_extend-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7bef0872c6d46fce41a63cc2d4d5b0c59d7cff12f4cb2cec7e266dbcdb152341
MD5 d475024b879118585f98e0484da3735d
BLAKE2b-256 718c4e117edae9824f84de65ef43c6307d165aeb39c5061ee2d6bb94e697ee8f

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_cli_extend-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on curskey/flask-cli-extend

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page