0
# Command Line Interface
1
2
Flask provides a CLI system for creating custom commands and managing applications from the command line.
3
4
## Capabilities
5
6
### CLI Functions
7
8
```python { .api }
9
def with_appcontext(f: Callable) -> Callable: ...
10
def load_dotenv(path: str | None = None) -> bool: ...
11
```
12
13
### CLI Classes
14
15
```python { .api }
16
class FlaskGroup(click.Group): ...
17
class AppGroup(click.Group): ...
18
```
19
20
## Usage Examples
21
22
### Custom Commands
23
24
```python
25
from flask import Flask
26
import click
27
28
app = Flask(__name__)
29
30
@app.cli.command()
31
def init_db():
32
"""Initialize the database."""
33
click.echo('Database initialized')
34
35
@app.cli.command()
36
@click.argument('name')
37
def create_user(name):
38
"""Create a new user."""
39
click.echo(f'User {name} created')
40
```