Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update CLI docs #211

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 17 additions & 13 deletions docs/docs/en/user-guide/cli/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,37 @@ The **FastAgency Command Line Interface (CLI)** enables developers to manage and

### `dev`
```bash
$ fastagency dev [OPTIONS] [PATH]
fastagency dev [OPTIONS] [PATH]
```
The `dev` command runs a FastAgency app in **development mode**, which is equivalent to running `fastapi` but with live reload enabled. This is useful for testing and development, as it listens on `127.0.0.1` and automatically detects the Python module or package that needs to be imported based on the file or directory path provided.
The `dev` command runs a FastAgency app in **development mode**, which is equivalent to running `fastagency run` but with live reload enabled. This is useful for testing and development, as it listens on `127.0.0.1` and automatically detects the Python module or package that needs to be imported based on the file or directory path provided.

#### Command Details:
- If no path is provided, it will try to locate the application using common file names like `main.py`, `app.py`, `api.py`, or from the `app` directory.
- It automatically detects the **FastAgency app** object to use, typically looking for an object named `app` or `api`.
- It automatically detects the **FastAgency app** object to use, typically looking for an object named `app` or `api`. If it cannot find either, it uses the first FastAgency app found in the imported module or package.

#### Common Options:
- `--app`: The name of the variable that contains the FastAgency app in the imported module. It defaults to automatic detection.
- `--workflow (-w)`: Specifies the name of the workflow to run.
- `--initial_message (-i)`: Sets the initial message sent to the workflow.
- `--app`: The name of the variable that contains the FastAgency app in the imported module or package. If not provided, it is detected automatically.
- `--workflow (-w)`: The name of the workflow to run. If not provided, the default workflow will be run.
- `--initial_message (-i)`: The initial message to send to the workflow. If not provided, a default message will be sent.

### `run`
```bash
$ fastagency run [OPTIONS] [PATH]
fastagency run [OPTIONS] [PATH]
```
The `run` command starts a FastAgency app in **production mode**, similar to the `dev` command, but optimized for production environments.
The `run` command starts a FastAgency app in **production mode**, similar to the `fastagency dev` command, but optimized for production environments.

#### Common Options for `run`:
- `--app`: Specifies the name of the app variable to run, like in `dev`.
- `--workflow (-w)`: Specifies a particular workflow to run.
- `--initial_message (-i)`: Sends a custom initial message to the workflow.
#### Command Details:
- If no path is provided, it will try to locate the application using common file names like `main.py`, `app.py`, `api.py`, or from the `app` directory.
- It automatically detects the **FastAgency app** object to use, typically looking for an object named `app` or `api`. If it cannot find either, it uses the first FastAgency app found in the imported module or package.

#### Common Options:
- `--app`: The name of the variable that contains the FastAgency app in the imported module or package. If not provided, it is detected automatically.
- `--workflow (-w)`: The name of the workflow to run. If not provided, the default workflow will be run.
- `--initial_message (-i)`: The initial message to send to the workflow. If not provided, a default message will be sent.

### `version`
```bash
$ fastagency version
fastagency version
```
The `version` command shows the currently installed version of FastAgency.

Expand Down
4 changes: 2 additions & 2 deletions fastagency/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def _run_app(
def _get_help_messages(dev_mode: bool = False) -> dict[str, str]:
help = f"""Run a [bold]FastAgency[/bold] app in [yellow]{'development' if dev_mode else 'production'}[/yellow] mode. 🚀

This is equivalent to [bold]fastapi run[/bold] but with [bold]reload[/bold] enabled and listening on the [blue]127.0.0.1[/blue] address.
{'This is similar to the [bold]fastagency run[/bold] command but with [bold]reload[/bold] enabled and listening on the [blue]127.0.0.1[/blue] address.' if dev_mode else 'This is similar to the [bold]fastagency dev[/bold] command, but optimized for production environments.'}

It automatically detects the Python module or package that needs to be imported based on the file or directory path passed.

Expand Down Expand Up @@ -131,7 +131,7 @@ def run(
)


@app.command(**_get_help_messages(False)) # type: ignore[arg-type]
@app.command(**_get_help_messages(True)) # type: ignore[arg-type]
def dev(
path: Annotated[
Optional[Path],
Expand Down