https://github.com/curskey/flask-cli-extend
Enhance Flask development workflow with powerful CLI commands for inspecting application.
https://github.com/curskey/flask-cli-extend
cli click command-line extension falsk-extension flask flask-plugins plugin
Last synced: 8 months ago
JSON representation
Enhance Flask development workflow with powerful CLI commands for inspecting application.
- Host: GitHub
- URL: https://github.com/curskey/flask-cli-extend
- Owner: curskey
- License: bsd-3-clause
- Created: 2025-07-18T16:48:38.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-07-18T18:23:22.000Z (8 months ago)
- Last Synced: 2025-07-18T19:49:35.964Z (8 months ago)
- Topics: cli, click, command-line, extension, falsk-extension, flask, flask-plugins, plugin
- Language: Python
- Homepage:
- Size: 43.9 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
# Flask-CLI-Extend
[](https://github.com/curskey/flask-cli-extend/actions/workflows/tests.yaml)
[](https://coveralls.io/github/curskey/flask-cli-extend?branch=main)
[](https://badge.fury.io/py/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
```bash
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:**
```python
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:**
```python
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.