> ## Documentation Index
> Fetch the complete documentation index at: https://docs.squarecloud.app/llms.txt
> Use this file to discover all available pages before exploring further.

# 用 CLI 管理应用

> 用 squarecloud app 列出你的 Square Cloud 应用，查看详情，启动、停止或重启应用，并删除不再需要的应用。

除 `list` 外，本页所有命令中的 `[appID]` 都是可选的：参见 [CLI 如何找到你的应用](/zh/cli-reference/quickstart#cli-如何找到你的应用)。

## `squarecloud app list`

```bash 用法 theme={"system"}
squarecloud app list [--json]
```

以表格列出你账户中的所有应用：名称、应用 ID、内存、集群、语言和域名（有自定义域名时显示自定义域名）。

```bash theme={"system"}
squarecloud app list --json
# 以 JSON 格式打印原始应用列表。
```

## `squarecloud app info`

```bash 用法 theme={"system"}
squarecloud app info [appID] [--json]
```

显示应用 ID、名称、描述、语言、内存、集群、拥有者、域名、自定义域名以及创建日期。

```bash theme={"system"}
squarecloud app info <appID> --json
# 以 JSON 格式打印原始应用对象。
```

## `squarecloud app start`

```bash 用法 theme={"system"}
squarecloud app start [appID]
```

启动一个已停止的应用。

```bash 输出 theme={"system"}
✓ Signal START has been successfully sent to your application.
```

如果应用已在运行，CLI 会说明这一点（`It is already running.`）并以退出码 0 退出。平台返回的其他拒绝会作为错误报告。

## `squarecloud app stop`

```bash 用法 theme={"system"}
squarecloud app stop [appID]
```

停止一个正在运行的应用。如果应用已停止，CLI 会说明这一点（`It is already stopped.`）并以退出码 0 退出。

## `squarecloud app restart`

```bash 用法 theme={"system"}
squarecloud app restart [appID]
```

重启应用的进程。要一步完成发送新代码和重启，请使用 [`squarecloud commit --restart`](/zh/cli-reference/deploy#squarecloud-commit)。

## `squarecloud app delete`

```bash 用法 theme={"system"}
squarecloud app delete [appID] [-y]
```

| 标志 | 说明 |
| - | - |
| `-y`, `--yes` | 跳过确认提示。 |

<Warning>
  删除应用是永久性的，CLI 不会事先创建 snapshot。如需保留副本，请在删除前运行 [`squarecloud app snapshot create --download`](/zh/cli-reference/snapshots#squarecloud-app-snapshot-create)。
</Warning>

删除前会询问 `Delete the application <appID>? This action is irreversible [y/N]`。不传 ID 时，该命令针对的是当前文件夹 `ID=` 行中的应用，因此请核对问题中显示的 ID。

```bash theme={"system"}
squarecloud app delete <appID> -y
# 不经询问直接删除，适用于脚本。
```

```bash 输出 theme={"system"}
✓ Your application has been deleted.
```

## 相关内容

| 命令 | API | JavaScript SDK | VS Code |
| - | - | - | - |
| `list` | [`GET /v2/users/me`](/zh/api-reference/endpoint/users/me) | [`api.account.me()`](/zh/sdks/js/client) | [侧边栏](/zh/vscode-extension/features#应用) |
| `info` | [`GET /v2/apps/{app_id}`](/zh/api-reference/endpoint/apps/info) | [`api.apps.get()`](/zh/sdks/js/managing_application) | 点击应用卡片 |
| `start` | [`POST .../start`](/zh/api-reference/endpoint/apps/start) | [`api.apps.start()`](/zh/sdks/js/managing_application) | [启动](/zh/vscode-extension/features#应用) |
| `stop` | [`POST .../stop`](/zh/api-reference/endpoint/apps/stop) | [`api.apps.stop()`](/zh/sdks/js/managing_application) | [停止](/zh/vscode-extension/features#应用) |
| `restart` | [`POST .../restart`](/zh/api-reference/endpoint/apps/restart) | [`api.apps.restart()`](/zh/sdks/js/managing_application) | [重启](/zh/vscode-extension/features#应用) |
| `delete` | [`DELETE /v2/apps/{app_id}`](/zh/api-reference/endpoint/apps/delete) | [`api.apps.delete()`](/zh/sdks/js/managing_application) | [删除](/zh/vscode-extension/features#应用) |
