Metadata-Version: 2.4
Name: flask-cli-extend
Version: 0.1.0
Summary: Enhance Flask development workflow with powerful CLI commands for inspecting application.
Keywords: flask,cli,command-line,plugin,extension
Author-email: curskey <curskey@proton.me>
Requires-Python: >=3.10
Description-Content-Type: text/markdown
Classifier: Framework :: Flask
Classifier: Environment :: Web Environment
Classifier: Intended Audience :: Developers
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: BSD License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3 :: Only
License-File: LICENSE
Requires-Dist: flask>=3.0
Project-URL: Issue, https://github.com/curskey/flask-cli-extend/issues/
Project-URL: Source, https://github.com/curskey/flask-cli-extend

# 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.

