本文包含自动补全、彩色输出、debug 日志和常见问题。这些能力不是调用 API 的必需步骤,但能提升日常使用效率和排障效率。
CLI 支持生成 Bash、Zsh、fish 和 PowerShell 的补全脚本:
ve completion --help临时启用:
source <(ve completion bash)每次打开 shell 自动启用:
echo 'source <(ve completion bash)' >> ~/.bashrc
source ~/.bashrc系统级安装:
ve completion bash > /etc/bash_completion.d/veBash 补全依赖 bash-completion。安装和检查:
# CentOS/RHEL
yum install bash-completion
# Debian/Ubuntu
apt-get install bash-completion
# 启用
source /usr/share/bash-completion/bash_completion
# 检查
type _init_completion如果出现 _get_comp_words_by_ref: command not found,通常是 bash-completion 未安装或未 source。
macOS 使用 Homebrew 时:
ve completion bash > "$(brew --prefix)/etc/bash_completion.d/ve"如果还没有启用 compinit:
echo "autoload -U compinit; compinit" >> ~/.zshrc安装补全脚本:
ve completion zsh > "${fpath[1]}/_ve"重新打开 shell,或执行:
source ~/.zshrc临时启用:
ve completion fish | source每次打开 shell 自动启用:
mkdir -p ~/.config/fish/completions
ve completion fish > ~/.config/fish/completions/ve.fish临时启用:
ve completion powershell | Out-String | Invoke-Expression保存脚本后,可在 PowerShell profile 中 source:
ve completion powershell > ve.ps1CLI 默认输出 JSON。可以启用彩色显示,便于终端阅读:
ve enable-color关闭彩色显示:
ve disable-color这两个命令会修改配置文件中的 enableColor。彩色输出影响 ve configure get、ve configure list 和 API 响应 JSON 的展示,不改变响应内容。
CLI debug 日志用于定位配置解析、参数构造和 SDK 调用问题。开启方式是设置环境变量:
VOLCENGINE_CLI_DEBUG=true ve sts GetCallerIdentity关闭值:
VOLCENGINE_CLI_DEBUG=false
VOLCENGINE_CLI_DEBUG=0
VOLCENGINE_CLI_DEBUG=off
VOLCENGINE_CLI_DEBUG=no
VOLCENGINE_CLI_DEBUG=其它非空值均视为开启。
开启后日志默认追加写入配置目录下的小时日志文件:
~/.volcengine/logs/YYYYMMDDHH.log
例如:
~/.volcengine/logs/2026061814.log
同一个小时内多次调用会追加到同一个文件。目录权限为 0700,日志文件权限为 0600。CLI 会拒绝写入符号链接或多硬链接日志文件,避免 debug 内容被追加到非预期文件。
debug 日志会记录:
- action 开始信息:service、action、version、method、content type。
- client 配置:profile 来源、凭证模式、region、endpoint、endpoint resolver、代理是否配置等。
- 参数构造结果:动态参数名、是否来自
--body、脱敏后的输入。 - SDK 请求尝试和请求结果。
- 错误阶段和耗时。
敏感字段会脱敏,例如 AK/SK、token、password、signature、private key 等常见字段。
排查示例:
VOLCENGINE_CLI_DEBUG=true ve sts GetCallerIdentity ---region cn-beijing
tail -n 100 ~/.volcengine/logs/$(date +%Y%m%d%H).logdebug 不是 CLI fixed flag。当前只通过 VOLCENGINE_CLI_DEBUG 环境变量开启:
VOLCENGINE_CLI_DEBUG=true ve sts GetCallerIdentity当前支持的 fixed flags 只有:
---profile, ---region, ---endpoint
API 调用时必须能解析到 region。设置方式按优先级为:
---region- profile 中的
region VOLCENGINE_REGION
示例:
ve sts GetCallerIdentity ---region cn-beijing或:
ve configure set --profile prod --region cn-beijing如果当前存在 current profile,CLI 会优先使用 profile。环境变量默认凭证链主要在没有活跃 profile 时使用。
可以临时指定 profile:
ve sts GetCallerIdentity ---profile prod也可以切换 current:
ve configure profile --profile prodve configure sso 只写入 SSO profile,不会切换 current。执行:
ve configure profile --profile my-devSSO:
ve configure sso --profile my-dev --sso-session my-sso --no-browser
ve sso login --sso-session my-sso --no-browserConsole Login:
ve login --profile dev --region cn-beijing --remote--body 只接受 JSON object 或 JSON array。检查引号和 shell 转义:
ve rds_mysql ModifyDBInstanceIPList \
--body '{"InstanceId":"mysql-xxxxxx","GroupName":"default","IPList":["10.20.30.40"]}'不要把 --body 和其它 API 参数混用。