多应用与 Profile
以下示例使用 goodvision;项目内安装后使用 npx --no-install goodvision。安装与首次配置见快速开始。
已有配置中添加另一个应用,不改变默认应用;config init --name <名称> 可指定首个 profile 名称:
bash
goodvision profile add --config ./goodvision.json --name second-sandbox \
--api-base "$GOODVISION_API_BASE" \
--docs-origin "$GOODVISION_DEVELOPER_DOCS_ORIGIN" \
--application "$GOODVISION_SECOND_APPLICATION_ID" \
--environment sandbox --token-file ./second-token
goodvision profile list --config ./goodvision.json
goodvision context --config ./goodvision.json --profile second-sandbox
goodvision profile use second-sandbox --config ./goodvision.jsonprofile list 展示应用、环境、凭据类型及默认标记,不读取或输出凭据。profile add 遇到重名拒绝覆盖;profile use 才会持久修改默认项。并发脚本使用每次调用的 --profile,不修改默认值。并发编辑失败时保留原配置;若遗留 .lock,先确认没有编辑进程,再处理该文件。
重命名或移除 Profile
bash
goodvision profile rename second-sandbox reader --config ./goodvision.json
goodvision profile use sandbox --config ./goodvision.json
goodvision profile remove reader --yes --config ./goodvision.jsonrename 保留应用、环境与凭据引用,重命名默认项时同步默认名称。remove 必须带 --yes,且拒绝移除默认项;先切换到其他项,最后一项不能移除。私有凭据文件可能供其他应用使用,移除配置不会删除它,也不会撤销服务端授权。
| 命令 | 说明 |
|---|---|
profile list | 查看所有应用上下文 |
profile add --name <名称> ... | 添加,不覆盖、不切默认 |
profile use <名称> | 持久切换默认项 |
profile rename <旧名称> <新名称> | 重命名,身份保持原样 |
profile remove <名称> --yes | 移除非默认配置 |
--profile <名称> <命令> | 单次选择,并发场景使用 |