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

# 发布与取消发布

CLI 的 `publish` 和 `unpublish` 命令用于控制 Sandbox Template 的可见性。\*\*发布(publish)\*\*会将 Template 公开给团队以外的所有人;\*\*取消发布(unpublish)\*\*则将其恢复为团队私有。二者底层都是通过设置 Template 的 `public` 标志实现的。

<Warning>
  **注意:** 默认情况下,该命令在更改可见性前会要求确认,并警告发布会使 Template 对团队以外的所有人公开。传入 `-y` / `--yes` 可跳过该确认提示。
</Warning>

***

## 前提条件

在环境变量中设置你的 API Key:

```bash theme={null}
export PPIO_API_KEY=<your API key>
```

***

## 用法

```bash theme={null}
# 发布（别名：tpl pb）
ppio template publish [template]

# 取消发布（别名：tpl upb）
ppio template unpublish [template]
```

`[template]` 参数是可选的。有三种方式可以选择要操作的 Template:

| 选择方式              | 行为                                |
| ----------------- | --------------------------------- |
| 传入 `[template]`   | 对指定 Template ID 对应的 Template 执行操作 |
| 省略 `[template]`   | 使用根目录下 `ppio.toml` 中定义的 Template  |
| `-s` / `--select` | 从交互式列表中选择(仅显示符合该操作条件的 Template)   |

### 选项

| 选项                     | 说明                                       |
| ---------------------- | ---------------------------------------- |
| `-p, --path <path>`    | 更改命令运行的根目录                               |
| `--config <ppio-toml>` | Sandbox 配置 toml 文件的路径(默认为 `./ppio.toml`) |
| `-s, --select`         | 从交互式列表中选择 Template                       |
| `-t, --team <team-id>` | 操作关联的团队 ID(与 `--select` 配合使用)            |
| `-y, --yes`            | 跳过手动确认提示                                 |

***

## 示例

```bash theme={null}
ppio template publish <templateID>
```

```bash theme={null}
ppio template publish -y
```

```bash theme={null}
ppio template unpublish --select --team <teamID>
```

发布成功后,会打印该 Template 发布时使用的公开名称:

```text theme={null}
- Publishing sandbox template <template>
  Published as: <name>
```
